Re enter car after 5 seconds

Hello, i’m trying to make a script when people leave the car they should get no access to enter it again, first after 5 seconds. This is how the script looks atm:


if Player:ExitVehicle() then 
	timer.Simple( 5, function() 
		print( "You can enter the car again in 5 seconds!")
	end )
end

Anybody there can help me? - Thanks.

First thing - ExitVehicle() is a function to make player LEAVE vehicle.
So okay. Another one Make for me please :> Np!



if SERVER then
util.AddNetworkString("TAL") 
	function NoEnterJerk( ply, ven ) 
	if !ply:IsValid() or !ven:IsValid() or !ply:IsPlayer() then return end -- Checking for no errors 
		ply.nej = CurTime() --Saving cur time, for check another enter to car
	end

	hook.Add("PlayerLeaveVehicle", "MakeForMePlease", NoEnterJerk)



	function NoEnterJerk_Check( ply, ven, role ) 
	if !ply:IsValid() or !ven:IsValid() or !ply:IsPlayer() then return end -- Another check for no errors
	if ply.nej == nil then
		return true
	end
		if ply.nej + 5 >= CurTime() then -- This check our saved time when player left dem car.
			local hmtm = ply.nej + 5 - CurTime()
			net.Start( "TAL" ) -- sending to player message that he have to try enter that car later.
				net.WriteString(hmtm)
			net.Send(ply)
		return false end
	end
	hook.Add("CanPlayerEnterVehicle", "MakeForMePlease_checking", NoEnterJerk_Check)
else
	net.Receive( "TAL", function(len)
		hmtm = net.ReadString()
		hmtm = math.Round( hmtm ) 
		local ply = LocalPlayer()
		chat.AddText( Color( 0,255,0 ), ply, Color(255,255,255), ", You have to wait ", Color( 0,0,255 ), tostring(hmtm), Color(255,255,255), "•sec, before you can enter this car again" )
	end)
end


Should works :slight_smile:
P.S. Re-codded client side. A bit nicer message :>

Ok thanks it works now :wink:

Maybe you should follow the link.

Sorry forgott to pool message name :> take a look at code I rewrote it.