Any way to reduce SpotLight distance movement lag?

I’m currently working on an alarm light system for my game but I’ve been encountering some annoying lighting behavior when the lights are spinning. I’m not sure if this is an engine bug or not so I’m posting this here. I run the lighting using TweenService on the client. The light models spin smoothly, but as seen below- the lighting doesn’t. Is there a way to fix this? Or a different way to spin the SpotLight that produces smoother behavior at distances? (The game’s performance runs fine on both mobile devices and lower-end devices)

This is what I’m experiencing (Light lags from this distance, then fixes as I get closer)
https://gyazo.com/86928e357820c480483e97961b7199ce

This is the alarm renderer part of my ClientRender LocalScript found in StarterPlayerScripts

local function doAlarms(enabled)
	if enabled == nil then
		return
	end
	if enabled == true then
		if AlarmValue.Sound.Value == true then
			workspace.GlobalSounds["3Tone"]:Play()
			delay(3.5,function()
				if AlarmValue.Sound.Value == true then
					workspace.GlobalSounds.MainAlarm:Play()
				end
			end)
		else
			workspace.GlobalSounds["1Tone"]:Play()
		end
		for _,Light in pairs(AlarmLights:GetChildren()) do
			if Light:IsA("Model") and Light:FindFirstChild("LightPart") and Light:FindFirstChild("LightCover") then
				Light.LightPart.SpotLight.Enabled = true
				Light.LightPart.Color = Color3.fromRGB(255,140,0)
				Light.LightPart.Material = Enum.Material.Neon
				Light.LightPart.Transparency = 0
			end
		end
		repeat wait()
			for _,Light in pairs(AlarmLights:GetChildren()) do
				if Light:IsA("Model") and Light:FindFirstChild("LightPart") and Light:FindFirstChild("LightCover") then
					TweenService:Create(Light.LightPart,TweenInfo.new(0.1),{CFrame = Light.LightPart.CFrame * CFrame.Angles(0,math.rad(10),0)}):Play()
					TweenService:Create(Light.LightCover,TweenInfo.new(0.1),{CFrame = (Light.LightPart.CFrame + Light.LightPart.CFrame.UpVector * 0.11) + Light.LightPart.CFrame.LookVector * 0.177}):Play()
				end
			end
		until AlarmValue.Value == false
	elseif enabled == false then
		for _,Light in pairs(AlarmLights:GetChildren()) do
			if Light:IsA("Model") and Light:FindFirstChild("LightPart") and Light:FindFirstChild("LightCover") then
				Light.LightPart.SpotLight.Enabled = false
				Light.LightPart.Color = Color3.fromRGB(255,255,255)
				Light.LightPart.Material = Enum.Material.Glass
				Light.LightPart.Transparency = 0.5
			end
		end
		workspace.GlobalSounds.MainAlarm:Stop()
	end
end
AlarmValue:GetPropertyChangedSignal("Value"):Connect(function()
	if AlarmValue.Value == true then
		doAlarms(true)
	elseif AlarmValue.Value == false then
		doAlarms(false)
	end
end)
if AlarmValue.Value == true then
	doAlarms(true)
elseif AlarmValue.Value == false then
	doAlarms(false)
end
1 Like

If I had to guess, I’d say its an internal optimization. You could report it as a bug anyway, it might still be.

1 Like