Are Dynmaic lights able to be viewed by client and server/all players? Help Please

Hey, i’m trying to get this light to be viewed by other players how would i do that?

function Light( ply )
local ply = LocalPlayer()
local veh = ply:GetVehicle()
		local rand = math.random(1,2)
		local dlight = DynamicLight( veh:EntIndex() )
		dlight.Pos = veh:GetPos()
		dlight.Brightness = 2
		dlight.Size = 4000
		dlight.Decay = 10
		dlight.DieTime = CurTime() + 0.7
		if rand == 1 then
		dlight.r = 125
		dlight.g = 0
		dlight.b = 0

		dlight.r = 0
		dlight.g = 0
		dlight.b = 125

DynamicLight is clientside. You must run it on each client individually for everyone else to see it like you do.

You must code it so that the code that executes Light() is ran on all clients and that the conditions for that are equal on all clients ( ie all functions/variables must return the same thing on all clients at all times )

I hope that makes some sense.

Well, that made sorta sense. I think your saying

-- When someone his the button or something
for k,v in pairs(player.GetAll()) do

Which doesn’t call all the players/ do to the players soo…
I’m not understanding that well xD

You are not passing the player object to your function, obviously it will not work.

Light( v )

Broadcast a net message, which when received, will execute that function.

^ Use a net message if you’re using DynamicLight(), otherwise just create a light_dynamic on the server. Really depends on the purpose of the light.