Scritp not work as soon as player respawn (SOLVED)


I do some stuff that work fine until player dies. When th player respawn, almost nothing work! Why almost: I make 2 script in lua, that do 2 thinks: the first affect player when he is in a car (he can’t exit the car), and the second add blip on map.

The player dies, it respawn, and all blip still there but when he go again in a car, he can exit the the car, and go again inside the car, exit ect…

Do we have something to do to be sure all work again at respawn?


Something is breaking in your script, don’t expect help unless you post the source code. It could literally mean anything.

You’re rigth! Here my source code:

Citizen.CreateThread(function ()
	while true do

		if IsPedSittingInAnyVehicle(GetPlayerPed(-1)) then
			SetPlayerWantedLevel(PlayerId(), 5, false)
			SetPlayerWantedLevelNow(PlayerId(), false)
			SetVehicleDoorsLocked(GetVehiclePedIsUsing(GetPlayerPed(-1)), 4)
			DrawMarker(1, 1031.5,-235.052,69.9436-1.0001, 0, 0, 0, 0, 0, 0, 8.0, 8.0, 2.0, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
				if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), 1031.5,-235.052,69.9436, true) > 4.0001 then
					return true
					TaskLeaveVehicle(GetPlayerPed(-1), GetVehiclePedIsUsing(GetPlayerPed(-1)), 0)
					SetPlayerWantedLevel(PlayerId(), 0, false)
					SetPlayerWantedLevelNow(PlayerId(), false)
			SetPlayerWantedLevel(PlayerId(), 0, false)
			SetPlayerWantedLevelNow(PlayerId(), false)



What is that?

A point on the map that I want that the player go to, when the player is at this point, the ped go outside the car and no problem with police anymore. I Will set a blip like that:

					--arrBlip = AddBlipForCoord(1031.5,-235.052,69.9436)
					--SetBlipSprite(arrBlip, 38)
					--SetBlipRoute(arrBlip, 1)

No, the function declaration

Sorry (native.lua line 10642):

function GetDistanceBetweenCoords(x1, y1, z1, x2, y2, z2, unknown)
	return _in(0xF1B760881820C952, x1, y1, z1, x2, y2, z2, unknown, _r, _rf)

before you go OMG TRY PASSING X/Y/Z SEPARATELY, realize that is irrelevant.

anyway, you’re returning true from your thread, ending the thread - that means after that code runs your thread won’t run anymore.

ok, I change it by a “Wait(0)” and all work fine now! Thank you!