Script Purpose: To make a light activate from a switch. Script: local BathLightCD = script.Parent.ClickDetector
BathLightCD.MouseClick:Connect(function(Clicked) game.Workspace.BathroomLight.Light.PointLight.Brightness = 10 if BathLightCD.RightMouseClick:Connect(function(Clicked) do game.Workspace.BathroomLight.Light.PointLight.Brightness = 0 end
end)
Notes: The point is it's talking about using ' then ' just when I do it wants me to use an identifier which I don't know what that is. Please help.
Firstly, the syntax for conditional statement is if .. then
not if .. do
. The compiler was throwing you error because if.. do
does not exist.
Secondly, You are creating a new function
in the if
statement. This is bound to throw you another error. Instead, you want to check if the Light
's Brightness
is either 10
or 0
. Also note that you do not need a parameter in the function
.
-- [Declaration Section] --\\ Part Location local Baseplate = workspace.Baseplate; local Light = Baseplate.PointLight; local ClickDetector = Baseplate.ClickDetector; -- [Processing Section] local function ChangeLight () if Light.Brightness == 0 then Light.Brightness = 10; print(Light.Brightness); else Light.Brightness = 0; print(Light.Brightness); end; end; -- [Connecting Section] ClickDetector.MouseClick:Connect(ChangeLight);