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

Renderstepped and filtering and enabled?

How does one go about taking this script: --In a server script with fe it works

local getlights = game.Workspace.Lights:GetChildren()
game:GetService("RunService").RenderStepped:connect(function()
	for i = 1, #getlights do
		if getlights[i].PointLight.Enabled == true then
			getlights[i].PointLight.Enabled = false
			print("all off")
		else
			getlights[i].PointLight.Enabled = true
			print("all on")
		end
	end
end)

and put it in a local script with fe, So it works in play mode.

1 answer

Don't see any problem here. However i would recommend using something that looks a bit cleaner, for example:

local getlights = workspace.Lights:GetChildren()

game:GetService("RunService").RenderStepped:connect(function()
	for i,v in pairs (getlights) do
		v.PointLight.Enabled = not v.PointLight.Enabled
	end
end)

4 comments

0

Problem is [RenderStepped] can not be ran from a Server Side Script through a server, it will however work in LocalScripts. Btw, kudos for using the not keyword to change the PointLight Enabled variable.

1

RunService can be used in a server script. RenderStepped can't.

0

Sorry, my bad.

0

Don't forget; There is also the 'HeartBeat' event of 'RunService' that fires 1/60th of a Second as well (at least, that's how it fire(d) for me). :)

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