Stoping a NPC

Hey everyone.
Alright so I been trying to make a script here when you aim at the PED which is the target they would stop and just put there hands up! thats it ! But i have no idea what im doing wrong or over looking…BTW I am new and learning so if this code looks weird and don’t make sense i ask if someone can just explain to me the issue please :slight_smile:

Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
if IsControlJustPressed(0, 48) then
ShowNotification(" Stop Right NOW")
local player = GetPlayerPed(-1)
local target = GetEntityPlayerIsFreeAimingAt(PlayerId())
if GetEntityType(target) == 1 and GetPedType(target) ~= 28 then
distanceToTarget = GetDistanceBetweenCoords(GetEntityCoords(player), GetEntityCoords(target))
if distanceToTarget <= 15 then
TaskHandsUp(target(-1), 1000, -1, -1, true)
SetPedAiBlipForcedOn(target, true)
ShowNotification("~o~ Ped shoould have hands up~o~ ")
end
end

Take a look at this, it may help you: