Can someone help with tweening Lighting?

I have this remote event that changes the lighting on a client’s screen. And I don’t know a way in which I could tween the Lighting based on how I have made the event.

--Server
local tabl = { 
	{String="Ambient", Value=Color3.fromRGB(0, 0, 0)},
	{String="Brightness", Value=0  },
	{String="FogEnd", Value=150  },
	{String="ClockTime", Value=0  },
	{String="FogColor", Value=Color3.fromRGB(0, 0, 0)  },
}

game:GetService("ReplicatedStorage").Lighting.ChangeLightingOnClient:FireClient(game.Players.nikguest,tabl)
--Client
game:GetService("ReplicatedStorage").Lighting.ChangeLightingOnClient.OnClientEvent:Connect(function(tabl)

	for i,v in pairs(tabl) do


		game:GetService("Lighting")[v["String"]] = v["Value"]


	end
end)

Reformat your table so we can easily tween the properties from the client. I did it for you anyway so here’s the new table:

local tabl = {
		["Ambient"] = Color3.fromRGB(0, 0, 0),
		["Brightness"] =  0,
		["FogEnd"] = 150,
		["ClockTime"] = 0,
		["FogColor"] = Color3.fromRGB(0, 0, 0)
	}

Now to modify the client side. This is easy to do now because all we have to do is pass the table onto the tween service and it will do everything. Here:

--Client
game:GetService("ReplicatedStorage").Lighting.ChangeLightingOnClient.OnClientEvent:Connect(function(tabl)

	local Lighting = game:GetService("Lighting")
	local Infotween = TweenInfo.new(3)
	
	game:GetService("TweenService"):Create(Lighting, Infotween, tabl):Play()

end)

Read about Tween service and the tween info here:

2 Likes

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