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

Please help me Mikeh?

Asked by 9 years ago
wait(1)
local act = _G.actvalue -- The global value
local inuse = false -- This is neccecary only for the script to not break and stuff, this needs to remain false.
_G["ALightsToggled"] = true

function alarmchange(alert)
    if not inuse then
        inuse = true
        if _G.actvalue == "Inactive" then
        local c = script.Parent:GetChildren()
        for i = 1, #c do
            if c[i].Name == "LightPart" then 
                if c[i]:FindFirstChild("PointLight") ~= nil then
                    c[i].PointLight.Brightness = 1
                elseif c[i]:FindFirstChild("SpotLight") ~= nil then     
                    c[i].SpotLight.Brightness = 1

        elseif _G.actvalue == "Red" then
        local c = script.Parent:GetChildren()
        for i = 1, #c do
            if c[i].Name == "LightPart" then
                if c[i]:FindFirstChild("PointLight") ~= nil then
                    c[i].PointLight.Brightness = 0.4
                elseif c[i]:FindFirstChild("SpotLight") ~= nil then     
                    c[i].SpotLight.Brightness = 0.4
end
            end
        end
    end
    end 


_G["AToggleLights"] = function()
    if _G["ALightsToggled"] == true then
        local c = script.Parent:GetChildren()
        for i = 1, #c do
            if c[i].Name == "LightPart" then
                if c[i]:FindFirstChild("PointLight") ~= nil then
                    c[i].PointLight.Enabled = true
                    c[i].BrickColor = BrickColor.new(226)
                elseif c[i]:FindFirstChild("SpotLight") ~= nil then     
                    c[i].SpotLight.Enabled = true
                    c[i].BrickColor = BrickColor.new(226)
                end
            end
        end
    elseif _G["ALightsToggled"] == false then
        local c = script.Parent:GetChildren()
        for i = 1, #c do
            if c[i].Name == "ALightPart" then
                if c[i]:FindFirstChild("PointLight") ~= nil then
                    c[i].PointLight.Enabled = false
                    c[i].BrickColor = BrickColor.new(1003)
                elseif c[i]:FindFirstChild("SpotLight") ~= nil then     
                    c[i].SpotLight.Enabled = false
                    c[i].BrickColor = BrickColor.new(1003)
                end
            end
        end
    end
    end 
1
You're not suppose to request help from just one person. Please post any errors or what you're trying to do including a question that tells other what you problem is. alphawolvess 1784 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

It seems that you have the incorrent amount of 'ends' needed. Quick Fix:

function alarmchange(alert)
    if not inuse then
        inuse = true
        if _G.actvalue == "Inactive" then
        local c = script.Parent:GetChildren()
        for i = 1, #c do
            if c[i].Name == "LightPart" then 
                if c[i]:FindFirstChild("PointLight") ~= nil then
                    c[i].PointLight.Brightness = 1
                elseif c[i]:FindFirstChild("SpotLight") ~= nil then     
                    c[i].SpotLight.Brightness = 1

        elseif _G.actvalue == "Red" then
        local c = script.Parent:GetChildren()
        for i = 1, #c do
            if c[i].Name == "LightPart" then
                if c[i]:FindFirstChild("PointLight") ~= nil then
                    c[i].PointLight.Brightness = 0.4
                elseif c[i]:FindFirstChild("SpotLight") ~= nil then     
                    c[i].SpotLight.Brightness = 0.4 
        end
            end
            end
            end
        end
        end
        end
    end
end
Ad

Answer this question