The lights turn off right when the first parts ends, I understand that. But how do you detect when a player clicks the same button to trigger two different functions?
local Button = script.Parent local Click = script.Parent.Click local State = script.Parent.State function onClick() Button.CFrame = CFrame.new(Button.Position - Vector3.new(0, 0.2, 0)) wait(0.01) Button.CFrame = CFrame.new(Button.Position + Vector3.new(0, 0.2, 0)) Click:Play() if State.Value == 0 then wait(1) script.Parent.Parent.One.Light.PointLight.Enabled = true script.Parent.Parent.Two.Light.PointLight.Enabled = true wait(1) script.Parent.Parent.Three.Light.PointLight.Enabled = true script.Parent.Parent.Four.Light.PointLight.Enabled = true wait(1) script.Parent.Parent.Five.Light.PointLight.Enabled = true script.Parent.Parent.Six.Light.PointLight.Enabled = true wait(1) script.Parent.Parent.Seven.Light.PointLight.Enabled = true script.Parent.Parent.Eight.Light.PointLight.Enabled = true State.Value = 1 end if State.Value == 1 then script.Parent.Parent.One.Light.PointLight.Enabled = false script.Parent.Parent.Two.Light.PointLight.Enabled = false wait(1) script.Parent.Parent.Three.Light.PointLight.Enabled = false script.Parent.Parent.Four.Light.PointLight.Enabled = false wait(1) script.Parent.Parent.Five.Light.PointLight.Enabled = false script.Parent.Parent.Six.Light.PointLight.Enabled = false wait(1) script.Parent.Parent.Seven.Light.PointLight.Enabled = false script.Parent.Parent.Eight.Light.PointLight.Enabled = false State.Value = 0 end end Button.ClickDetector.MouseClick:connect(onClick)
i think you should do like this:
local Button = script.Parent local Click = script.Parent.Click local State = script.Parent.State function onClick() Button.CFrame = CFrame.new(Button.Position - Vector3.new(0, 0.2, 0)) wait(0.01) Button.CFrame = CFrame.new(Button.Position + Vector3.new(0, 0.2, 0)) Click:Play() if State.Value == 0 then wait(1) script.Parent.Parent.One.Light.PointLight.Enabled = true script.Parent.Parent.Two.Light.PointLight.Enabled = true wait(1) script.Parent.Parent.Three.Light.PointLight.Enabled = true script.Parent.Parent.Four.Light.PointLight.Enabled = true wait(1) script.Parent.Parent.Five.Light.PointLight.Enabled = true script.Parent.Parent.Six.Light.PointLight.Enabled = true wait(1) script.Parent.Parent.Seven.Light.PointLight.Enabled = true script.Parent.Parent.Eight.Light.PointLight.Enabled = true State.Value = 1 else if State.Value == 1 then script.Parent.Parent.One.Light.PointLight.Enabled = false script.Parent.Parent.Two.Light.PointLight.Enabled = false wait(1) script.Parent.Parent.Three.Light.PointLight.Enabled = false script.Parent.Parent.Four.Light.PointLight.Enabled = false wait(1) script.Parent.Parent.Five.Light.PointLight.Enabled = false script.Parent.Parent.Six.Light.PointLight.Enabled = false wait(1) script.Parent.Parent.Seven.Light.PointLight.Enabled = false script.Parent.Parent.Eight.Light.PointLight.Enabled = false State.Value = 0 end end end Button.ClickDetector.MouseClick:connect(onClick)
hope it helps.