2016-07-29 2 views
1

안녕하세요 저는 Roblox의 사용자이고 4 개의 표시등을 끄는 조명 스위치를 스크립팅하려고합니다. 오류 (제목에 있음)Roblox 오류 : ')'(열 3의 '닫기') '='가 있습니다. '' ''가 있습니다.

Off4 및 On4 스위치가 2 개 사용 중입니다. 그 때문에 난 단지 스크립트에 사용하고 있습니다 :

내 코드

function OnClicked() 
if (workspace.LivingRoomLight.SpotLight.Enabled == true) and (workspace.LivingRoomLight2.SpotLight.Enabled == true) and (workspace.LivingRoomLight3.SpotLight.Enabled == true) and (workspace.LivingRoomLight4.SpotLight.Enabled == true) then 
    (workspace.LivingRoomLight.SpotLight.Enabled = false) and (workspace.LivingRoomLight2.SpotLight.Enabled == false) and (workspace.LivingRoomLight3.SpotLight.Enabled == false) and (workspace.LivingRoomLight3.SpotLight.Enabled == false) 
    script.Parent.Transparency = 1 
    workspace.Off4.Transparency = 0 
end 
end 
script.Parent.ClickDetector.MouseClick:connect(OnClicked) 

다른 스크립트

(즉 일) 나는 오직 하나의 빛을 사용하는 사람에 사용되는

function OnClicked() 
if (workspace.Hallwaylight.SpotLight.Enabled == true) then 
    workspace.Hallwaylight.SpotLight.Enabled = false 
    script.Parent.Transparency = 1 
    workspace.Off.Transparency = 0 
end 
end 
script.Parent.ClickDetector.MouseClick:connect(OnClicked) 

주입니다 오류가있는 파일에 대해 편집 한 유일한 파일입니다. 내가 사용하는 경우 스크립트에서의 오류 대신 '='는 다음 전체 라인이 오류

+0

대괄호 (if())가 아닌 조건 만 작업에 넣습니다. –

답변

1

에게이됩니다의 '=='3 열에서 첫 번째 =이며,이 시도 :

if (workspace.LivingRoomLight.SpotLight.Enabled == true) and (workspace.LivingRoomLight2.SpotLight.Enabled == true) and (workspace.LivingRoomLight3.SpotLight.Enabled == true) and (workspace.LivingRoomLight4.SpotLight.Enabled == true) then 
    workspace.LivingRoomLight.SpotLight.Enabled = false 
    workspace.LivingRoomLight2.SpotLight.Enabled = false 
    workspace.LivingRoomLight3.SpotLight.Enabled = false 
    workspace.LivingRoomLight4.SpotLight.Enabled = false 
    ... 

일부 포인터를 :

  • x == y는 "x 동일한 y합니까?"를 의미한다. 조건 (true 또는 false)입니다.
  • x = y은 "x에서 y으로 설정"을 의미합니다. (프로그램에 x의 값을 수정하라는 명령)입니다.
  • and조건을 왼쪽과 오른쪽으로 예상하는 연산자입니다.

여러분의 프로그램은

if (these four values are true) then 
    set each of them to false 
end 

그래서 당신이 and 및 첫 번째 줄에 == 필요로하는 형태이지만, 그들은 if 내부 이해가되지 않는다 - 당신이 거기, =를 사용하여 네 개의 간단한 문장을 필요로 .


당신은 정말 하지만== 필요가 없습니다. 부등 값 (예 : , 이는 이미 true 또는 false)을 true에 비교하는 것은 다소 바보입니다. if x == true then ... end 대신 if x then ... end을 쓰는 것이 좋습니다.

+0

완벽하게 일했습니다! 고맙습니다! – Austinsoevil81

+0

기쁩니다 :) 내 대답을 수락 할 수 있습니까 (✓를 클릭하십시오) 그러면 질문이 해결 된 것으로 나타납니다. – Lynn

+0

만약 그들이 '만약'을 이해하지 못한다면, 나는 그들을 'for'에 대해 가르치 려하지 않습니다. 코드 스 니펫을 작성하는 것은 상처를 입히지 만, 초보자도 집중적 인 Q & A 경험이 있어야합니다. OP의 질문은 '~에 관한'것이 아닙니다. – Lynn

관련 문제