Why does my this not work? HELP Please!

Hello, I’m trying to get my rest of my code but all my errors lead to this.
By the way, i hidden some of the text because its some of my projects coming out.
It says…



local veh = LocalPlayer():GetVehicle()


init.lua is serverside, LocalPlayer() is clientside

Alright, so then how am i able to call ply which is LocalPlayer()?

Show the rest of the function.

Sorry for the delay.



local siren = false

hook.Add("KeyPress", "S_KeyPress", function(ply, key)

	if ply:KeyPressed(IN_ATTACK2) and ply:InVehicle() then

		if siren then
				ply:ChatPrint("ON")
			Siren( ply )

		else
				ply:ChatPrint("OFF")
			offsiren( ply )
		end

		siren = not siren
		
	end

end )

function onsiren(ply)

	local STimer = 2

	timer.Create( "Siren", 1, STimer, function()

		STimer = STimer - 1

		if STimer == 0 then
			STimer = math.random(1,2)
			RSiren( ply )
		end

	end)
end

function Siren(ply)

	local veh = LocalPlayer():GetVehicle()

/*	if driver and LocalPlayer():GetDriver() then

		veh:EmitSound("sound/vehicles/Siren.wav")

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

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

		end*/
ply:ChatPrint("SIREN TESTIES")

timer.Simple( 2, function() StartSiren() end )
end

function StartSiren(ply)

Siren(ply)

end

function offsiren()

	timer.Stop("Siren")

end


ply:GetVehicle() instead of LocalPlayer():GetVehicle(), same for the GetDriver().

I just realized my problem there… I was working on this late at a night sorry… let me see if its fixes it!

Alright i spent two days figuring out the bugs… Which i have it all done… But one problem is other players don’t see the lights besides the driver.

Post your new code.