I couldn't make only "police" jobs can toggle this command with if xPlayer.job.name == "police" then
this code but it didn't worked as I planed
local xPlayers = ESX.GetPlayers()
RegisterNetEvent("pepperspray:Togglepepperspray")
AddEventHandler("pepperspray:Togglepepperspray", function()
if not holdingpepperspray then
RequestModel(GetHashKey(peppersprayModel))
while not HasModelLoaded(GetHashKey(peppersprayModel)) do
Citizen.Wait(100)
end
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Citizen.Wait(100)
end
end
you can do like this :
Dont use your first line of your script, because is just use during the script load. For efficiency, use it only when you need on a function and before a for or while.