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

Why is my script not detecting bool value changing?

Asked by 2 years ago

I have this flashlight tool that has bool value named "Broken" in it that is set to false If its true script should turn off flashlight until "Broken" is set to false again but for some reason it doesnt work (Normal script)

local on = false
local broken = script.Parent:FindFirstChild("Broken")

local function turnoffflashlight()
    if broken.Value == true then
        script.Parent.Light.Shadow.Enabled = false
        script.Parent.Light.Light.Enabled = false
        script.Parent.Front.SurfaceLight.Enabled = false
    end
end





script.Parent.Activated:Connect(function()
    if on == false then
        on = true
        script.Parent.Light.Sound:Play()
        if broken.Value == true then
                  print("Broken")
        else
            script.Parent.Light.Shadow.Enabled = true
            script.Parent.Light.Light.Enabled = true
            script.Parent.Front.SurfaceLight.Enabled = true
        end
    elseif on == true then
        on = false
        script.Parent.Light.Sound2:Play()
        if broken.Value == true then
                 print("Broken")
        else
            script.Parent.Light.Shadow.Enabled = false
            script.Parent.Light.Light.Enabled = false
            script.Parent.Front.SurfaceLight.Enabled = false
        end
    end
end)

broken:GetPropertyChangedSignal("Value"):Connect(turnoffflashlight)

even with all these if's flashlight works

0
I had a problem just like that before and i have no idea what to do about it blackcatbabydragon 12 — 2y

Answer this question