Handcuff function isn't stopping after request

I’m using this function and what I’m trying to do is stop it if they are already doing the animation. However when I attempt to stop the physical animation stops but the players can’t pull out weapons or steer in a vehicle.

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(10)
		
				
		if (handCuffed) then
			RequestAnimDict('mp_arresting')

			while not HasAnimDictLoaded('mp_arresting') do
				Citizen.Wait(0)
			end

			local myPed = PlayerPedId(-1)
			local animation = 'idle'
			local flags = 49
			
			while(IsPedBeingStunned(myPed, 0)) do
				ClearPedTasksImmediately(myPed)
			end
			TaskPlayAnim(myPed, 'mp_arresting', animation, 8.0, -8, -1, flags, 0, 0, 0, 0)
		end

Why are you triggering the animation to run every 10 ms? You could keep the loop but I wouldn’t run that whole block of code unless its not already playing the animation.

1 Like