Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

PointLight Enabled then Disabled? (Edited!)

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)

1 comment

0

Now it only flashes once, but then get's stuck

3 answers

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 :)

1 comment

0

Thank's but I wanted the Pointlight to make a flashing effect until someone clicks it again

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)

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

3 comments

0

The error is still on "else" .

0

Well, there is no if statement, so you can't do else.

0

I edited the answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.