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

Please could someone tell me why this simple function thing script won't work?

function On()
	game.Workspace.Lava.Pointlight.Enabled = true 
end

function Off()
	game.Workspace.Lava.Pointlight.Enabled = false 
end

while true do 
	On()
	wait(3)
	Off()
	wait(3)
end

Also I know theres much easier ways to do it but it has to be the functions in the while true do loop that's the thing im trying to get to work, does anyone know how to make functions work in while true loop

4 comments

0

Try making the functions local (local function On/Off())

0

are you getting any errors?

0

No errors

0

I'm not sure about this, but I do not think you need any function to use this

2 answers

Make sure this is in a server script and also make sure you put a local before your functions so it will happen if it's own scope.

Here's your script:

local function On()
    game.Workspace.Lava.Pointlight.Enabled = true 


local function Off()
    game.Workspace.Lava.Pointlight.Enabled = false 

while true do 
    On()
    wait(3)
    Off()
    wait(3)
end
end
end

2 comments

0

Thank u

0

Accept my answer

Yeah, what I said earlier about not needing functions, is true, make sure to put a script inside the PointLight and put this in the script (I tested it, it works)

while true do
	script.Parent.Brightness = 0
	wait(1)
	script.Parent.Brightness = 3
	wait(1)
end

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