Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Light Not toggling on click?

Asked by 3 years ago

I want to make it so that when i click a light switch the light should toggle

objects : Light > PointLight

Second Object : LightSwitch(Model) > ClickDetector > LightControllerScript , BoolLight(BoolValue)

Parent Object : StartingArea(Model, Is a room)

LightControllerScript :

script.Parent.MouseClick:Connect(function()

    if script.Parent.BoolLight.Value == true then
        workspace.StartingArea.Light.PointLight.Brightness = 0
        workspace.StartingArea.Light.Material = 'Glass'
        script.Parent.BoolLight.Value = false
    end

    if script.Parent.BoolLight.Value == true then
        workspace.StartingArea.Light.PointLight.Brightness = 1
        workspace.StartingArea.Light.Material = 'Neon'
        script.Parent.BoolLight.Value = false
    end

    print('Light has been triggered')
end)

Console : Light has been triggered

And yet Nothing happened to the light it still remains on and never changes

0
I think the problem is that you have 2 if statements with the same condition tuanorn 6 — 3y
0
Thanks tuanorn! you were right i used an else statement and it suddenly worked Thank you so much! florentin889 2 — 3y

Answer this question