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

Renderstepped and filtering and enabled?

Asked by
NotSoNorm 777 Moderation Voter
8 years ago

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

Log in to vote
4
Answered by 8 years ago

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)

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. M39a9am3R 3210 — 8y
1
RunService can be used in a server script. RenderStepped can't. CodingEvolution 490 — 8y
0
Sorry, my bad. M39a9am3R 3210 — 8y
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). :) TheeDeathCaster 2368 — 8y
Ad

Answer this question