SpotLights look really blocky and choppy

I don’t really know if this is because of my code or not. Take a look at this video:

Here’s the flicker Module Script:

local module = {}

local TS = game:GetService("TweenService")

function module:flicker(folder, flickers, flickertime, restorepause, restoretime)
	for i, object in ipairs(folder:GetChildren()) do
		coroutine.wrap(function()
			local light = object.SpotLight -- get the spotlight
			local baselight = light.Brightness

			for i = 1, flickers do -- repeat "flickers" amount of times 
				light.Brightness = baselight -- set to normal
				task.wait(flickertime * math.random(0.85, 1.15))
				light.Brightness = 0 -- cut the lights
				task.wait(flickertime * math.random(0.85, 1.15))
			end

			-- note that it ends on a blank light

			-- tween system
			task.wait(restorepause)
			
			local properties = {Brightness = baselight}
			local lightinfo = TweenInfo.new(
				restoretime * math.random(0.85, 1.15),
				Enum.EasingStyle.Quint,
				Enum.EasingDirection.InOut,
				0,
				false,
				0
			)
			local lighttween = TS:Create(light, lightinfo, properties)
			lighttween:Play()
		end)()
	end
end

return module

Script Call:

local flickerlights = require(game:GetService("ReplicatedStorage").Modules.FlickerLights)

while task.wait(5) do
	local folder = game:GetService("Workspace").Lights
	flickerlights:flicker(folder, 20, 0.05, 1, 0.5)
end

I doubt that the scripts have anything to do with it, but better safe than sorry. Is this the right place to ask this question? I don’t really know what’s causing this blockiness…

(Also, unrelated but, anyone know how to fix the insane lag when I try and playtest? Massive FPS drop and a bit of unresponsiveness when joining the server. After that it’s completely fine. I had no scripts open, which I know can cause a bit of the playtest lag.)

Thinking about it, it’s probably better if I ask this in #help-and-feedback:building-support :confused:

A good idea is to make the brightness to 0 smoothly.
For example:

local TweenService = game:GetService("TweenService")


local goal = {}
goal.Brightness = 0


local tweenInfo = TweenInfo.new(0.1)

local tween = TweenService:Create(light, tweenInfo, goal)

tween:Play()

This should do it.
You can also try putting the graphics on max.

Results:

Thanks, I figured out it was because my graphics was too low.
I’ll definitely implement this - I didn’t think about tweening the flickers, and only tweening the restart.
Thanks a lot!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.