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

PointLight Enabled then Disabled? (Edited!)

Asked by 10 years ago

I am trying to make it so when you click a Button, it makes a PointLight go on and off for a set time, but I am stuck on the "else" part.

script.Parent.MouseButton1Click:connect(function()
    if game.Workspace["DJ Board (PRO)"].Lights.One.PointLight.Enabled == false then
        while true do
            game.Workspace["DJ Board (PRO)"].Lights.One.PointLight.Enabled = true
            wait(1)
            game.Workspace["DJ Board (PRO)"].Lights.One.PointLight.Enabled = false
        end
    else
        game.Workspace["DJ Board (PRO)"].Lights.One.PointLight.Enabled = false
    end
    end)
0
Now it only flashes once, but then get's stuck ScriptingHelpersALT 20 — 10y

3 answers

Log in to vote
1
Answered by
HexC3D 830 Moderation Voter
10 years ago
x = false
script.Parent.MouseButton1Click:connect(function()

   if x == false then
        script.Parent.Parent.Parent.Parent.Lights.One.PointLight.Enabled = true
        x = true
end
if x == true then
script.Parent.Parent.Parent.Parent.Lights.One.PointLight.Enabled = true
x = false
end
end)

This is an Off/On Switch.

If I answered this question Check Mark :)

0
Thank's but I wanted the Pointlight to make a flashing effect until someone clicks it again ScriptingHelpersALT 20 — 10y
Ad
Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago
a = script.Parent.Parent.Parent.Parent.Lights.One.PointLight.Enabled
b = false
script.Parent.MouseButton1Click:connect(function()
    if b == false then
        b = true
        while b == true do
            a = true
            wait(0.1)
            a = false
            end
    elseif b == true then
        b = false
        a = false
    end
end)
Log in to vote
-1
Answered by 10 years ago

EDIT #1

You need it an If Statement, this should work.

if script.Parent.MouseButton1Click then
    while true do
        wait(1)
        script.Parent.Parent.Parent.Parent.Lights.One.PointLight.Range = 60
        print("Button Clicked")
        else
  script.Parent.Parent.Parent.Parent.Lights.One.PointLight.Range = 0
end
end
0
The error is still on "else" . ScriptingHelpersALT 20 — 10y
0
Well, there is no if statement, so you can't do else. Grenaderade 525 — 10y
0
I edited the answer. Grenaderade 525 — 10y

Answer this question