Okay so in roblox i have been trying to make a flickering light but it doesn't seem work. So i have tried finding what my error in line one is but.. it doesn't seem to work and i can't seem to find it.
asked Oct 28, 2020 at 15:38
You can edit the "wait(time)" as you wish to speed up the flickering or slow it down. answered Nov 23, 2020 at 17:59 Download – Flickering Lights Model and ScriptHow To – Make Flickering Lights in Roblox StudioWhat’s up everyone, BuzzyBeth here – In this tutorial we’ll be learning how to make flickering lights at random intervals!
Posted by8 years ago Archived So I feel a little silly for asking, but how do I create a flickering light? More specifically how do I make it so that a brick changes in between two, three, or more point lights? Like if I wanted a flickering fire effect or some sort of crazy rave thing going on. I tried to reverse engineer free models that incorporated flickering point lights but I have yet to come to a conclusion. Some help would be mighty grateful. Answered by 10 months ago A Little code I whipped up. Might need further testing, but this code you can configure when it flashes and how long the intervals between the flashes. I've also added a PointLight You may need to change this depending on what light source you're using!. Server Script!!: Heres the code!: local Light = script.Parent -- Our Light local PointLight = Light:FindFirstChild("PointLight",10) -- the PointLight Object, You may need to change this! local FlickerInt = 3 -- seconds this light flickers local OffFlickerInt = 10 -- How much time to make this light not flicker in seconds! local FlickerAtStart = true -- Do we flicker at the start of the game or not? local FlickerRandomness = true -- is our flicker point random or not? local MaxRandomTimeBetweenFlickers = 5 local MinRandomTimeBetweenFlickers = 1 --// Below this line is internal variables these are set as this script is run! --// ========================================================================== local bisFlickering = false local t = 0 local StartTime = tick() -- Get the time this game started at in mili-secs local LightMode = 1 local Saved = { PointLight = (function() if(PointLight ~= nil) then return { Enabled = PointLight.Enabled, Range = PointLight.Range, Color = PointLight.Color, Brightness = PointLight.Brightness } else return nil end end)(), FlickerInt = FlickerInt, OffFlickerInt = OffFlickerInt, FlickerAtStart = FlickerAtStart , FlickerRandomness = FlickerRandomness, MaxRandomTimeBetweenFlickers = MaxRandomTimeBetweenFlickers, MinRandomTimeBetweenFlickers = MinRandomTimeBetweenFlickers } --// ========================================================================== --// end of internal varibles --// Main Loopy! while true do t = tick() -- Grab Game Tick(frame) time!... local DT = t - StartTime -- Subtract the tick time from StartTime, this gives us the seconds since last update. Simular to workspace.DistributedGameTime but more accurate! if(FlickerAtStart == true) then -- do we flicker at start? if(DT <= FlickerInt) then -- Time is still under Flicker time! bisFlickering = true else -- Right we're Done flikering lets rest and reset the StartTime for next time!... StartTime = tick() bisFlickering = false FlickerAtStart = false end end if(bisFlickering == true) then-- Main Flicker if Statement, are we flickering? if(DT <= FlickerInt) then -- if DT is les then our Flicker time then randomise the LightIntensitiy via LightMode LightMode = math.random() else -- We're Not Flikering lets reset everything LightMode = 1 bisFlickering = false if(FlickerRandomness == true) then OffFlickerInt = math.random(MinRandomTimeBetweenFlickers,MaxRandomTimeBetweenFlickers) else OffFlickerInt = Saved.OffFlickerInt end end else -- Nope Not Flikering Lets rest.... LightMode = 1 if(DT<= OffFlickerInt) then -- Snooore.......*PFFFT*..... Snoore..... bisFlickering = false else -- Wake up we're Flickering!.... StartTime = tick() bisFlickering = true end end --// Talk to our light Brick and if available our PointLight Light.Color = Color3.fromHSV(0, 0, LightMode) if(PointLight ~= nil) then PointLight.Range = (LightMode*100 / Saved.PointLight.Range) * 10 end -- allways waiting.... No seriously, removing this will hang the game! wait() end Hopefully i've added some useful comments. If not, let me know. Oh! and simply put this script inside the light you want to flicker randomly. Also if you want it to talk to your Light Object just change line 2 to the name of your Light Object. Hope this helps! :) |