Emote for 5 seconds


#1

Hello,

I’ve got a problem with my script:
I try to play a emote only for 5 seconds, and then doing some stuff

Here the code:

AddEventHandler('pickalock', function()
ped = GetPlayerPed(-1);
local pos = GetEntityCoords(GetPlayerPed(-1))
local vehicle = GetClosestVehicle(pos['x'], pos['y'], pos['z'], 5.001, 0, 70)
if DoesEntityExist(vehicle) then
if ped then
		TaskStartScenarioInPlace(ped, "WORLD_HUMAN_WELDING", 0, true);
	end
	Wait(5000)
	ClearPedTasks(ped);
SetVehicleDoorsLocked(vehicle,4)
end
end)

With this code, the vehicle is unlock, but the player don’t play the emote.

If i remove “ClearPedTasks(ped);” the player play the emote, but he’s stuck in the emote. (Can’t move, and the emote never stop)
I try to replace wait(5000) with Citizen.Wait(5000), or just replace 5000 with 50000, but always the same problem.

Can you help me?

Thank you :slight_smile:


#2

Is this your full script? Or just the AddEventHandler?


#3

It’s just the AddEventHandler.
The full script is a GUI Menu to call the AddEventHandler.