Need help getting a script to work

I found this script on the github but when I try to use it it don’t do anything still the regular gta weapon draw animation and I’m still very new to scripting so idk what looks wrong in the code any help would be amazing thanks.

local holstered = true

local weapons = {
“WEAPON_PISTOL”,
“WEAPON_COMBATPISTOL”,
“WEAPON_STUNGUN”,
“WEAPON_APPISTOL”,
“WEAPON_PISTOL50”,
“WEAPON_SNSPISTOL”,
“WEAPON_HEAVYPISTOL”,
“WEAPON_VINTAGEPISTOL”,
“WEAPON_FLAREGUN”,
“WEAPON_REVOLVER”,
“WEAPON_MINISMG”,
“WEAPON_SWITCHBLADE”,
“WEAPON_MACHETE”,
“WEAPON_KNUCKLE”,
“WEAPON_MARKSMANPISTOL”,
“WEAPON_HATCHET”,
“WEAPON_DAGGER”,
“WEAPON_BOTTLE”,
“WEAPON_BALL”,
“WEAPON_SMOKEGRENADE”,
“WEAPON_BZGAS”,
“WEAPON_MICROSMG”,
“WEAPON_SAWNOFFSHOTGUN”,
“WEAPON_CROWBAR”,
“WEAPON_HAMMER”,
“WEAPON_KNIFE”,
“WEAPON_MOLOTOV”,
“WEAPON_FLARE”,
“WEAPON_SNOWBALL”,
“WEAPON_WRENCH”,
“WEAPON_NIGHTSTICK”
}

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local ped = PlayerPedId()
if DoesEntityExist( ped ) and not IsEntityDead( ped ) and not IsPedInAnyVehicle(PlayerPedId(), true) then
loadAnimDict( “reaction@intimidation@1h” )
if CheckWeapon(ped) then
if holstered then
TaskPlayAnim(ped, “reaction@intimidation@1h”, “outro”, 8.0, 2.0, -1, 48, 10, 0, 0, 0 )
Citizen.Wait(600)
ClearPedTasks(ped)
holstered = false
end
SetPedComponentVariation(ped, 9, 0, 0, 0)
else if not CheckWeapon(ped) then
if not holstered then
TaskPlayAnim(ped, “reaction@intimidation@1h”, “intro”, 8.0, 2.0, -1, 48, 10, 0, 0, 0 )
Citizen.Wait(500)
ClearPedTasks(ped)
holstered = true
end
SetPedComponentVariation(ped, 9, 1, 0, 0)
end
end
end
end)

function CheckWeapon(ped)
for i = 1, #weapons do
if GetHashKey(weapons[i]) == GetSelectedPedWeapon(ped) then
return true
end
end
return false
end

function loadAnimDict( dict )
while ( not HasAnimDictLoaded( dict ) ) do
RequestAnimDict( dict )
Citizen.Wait( 0 )
end
end

please put it in a script form like

this
local holstered = true

local weapons = {
“WEAPON_PISTOL”,
“WEAPON_COMBATPISTOL”,
“WEAPON_STUNGUN”,
“WEAPON_APPISTOL”,
“WEAPON_PISTOL50”,
“WEAPON_SNSPISTOL”,
“WEAPON_HEAVYPISTOL”,
“WEAPON_VINTAGEPISTOL”,
“WEAPON_FLAREGUN”,
“WEAPON_REVOLVER”,
“WEAPON_MINISMG”,
“WEAPON_SWITCHBLADE”,
“WEAPON_MACHETE”,
“WEAPON_KNUCKLE”,
“WEAPON_MARKSMANPISTOL”,
“WEAPON_HATCHET”,
“WEAPON_DAGGER”,
“WEAPON_BOTTLE”,
“WEAPON_BALL”,
“WEAPON_SMOKEGRENADE”,
“WEAPON_BZGAS”,
“WEAPON_MICROSMG”,
“WEAPON_SAWNOFFSHOTGUN”,
“WEAPON_CROWBAR”,
“WEAPON_HAMMER”,
“WEAPON_KNIFE”,
“WEAPON_MOLOTOV”,
“WEAPON_FLARE”,
“WEAPON_SNOWBALL”,
“WEAPON_WRENCH”,
“WEAPON_NIGHTSTICK”
}

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local ped = PlayerPedId()
if DoesEntityExist( ped ) and not IsEntityDead( ped ) and not IsPedInAnyVehicle(PlayerPedId(), true) then
loadAnimDict( “reaction@intimidation@1h” )
if CheckWeapon(ped) then
if holstered then
TaskPlayAnim(ped, “reaction@intimidation@1h”, “outro”, 8.0, 2.0, -1, 48, 10, 0, 0, 0 )
Citizen.Wait(600)
ClearPedTasks(ped)
holstered = false
end
SetPedComponentVariation(ped, 9, 0, 0, 0)
else if not CheckWeapon(ped) then
if not holstered then
TaskPlayAnim(ped, “reaction@intimidation@1h”, “intro”, 8.0, 2.0, -1, 48, 10, 0, 0, 0 )
Citizen.Wait(500)
ClearPedTasks(ped)
holstered = true
end
SetPedComponentVariation(ped, 9, 1, 0, 0)
end
end
end
end)

function CheckWeapon(ped)
for i = 1, #weapons do
if GetHashKey(weapons[i]) == GetSelectedPedWeapon(ped) then
return true
end
end
return false
end

function loadAnimDict( dict )
while ( not HasAnimDictLoaded( dict ) ) do
RequestAnimDict( dict )
Citizen.Wait( 0 )
end
end
local holstered = true

local weapons = {
  "WEAPON_PISTOL",
  "WEAPON_COMBATPISTOL",
  "WEAPON_STUNGUN",
  "WEAPON_APPISTOL",
  "WEAPON_PISTOL50",
  "WEAPON_SNSPISTOL",
  "WEAPON_HEAVYPISTOL",
  "WEAPON_VINTAGEPISTOL",
  "WEAPON_FLAREGUN",
  "WEAPON_REVOLVER",
  "WEAPON_MINISMG",
  "WEAPON_SWITCHBLADE",
  "WEAPON_MACHETE",
  "WEAPON_KNUCKLE",
  "WEAPON_MARKSMANPISTOL",
  "WEAPON_HATCHET",
  "WEAPON_DAGGER",
  "WEAPON_BOTTLE",
  "WEAPON_BALL",
  "WEAPON_SMOKEGRENADE",
  "WEAPON_BZGAS",
  "WEAPON_MICROSMG",
  "WEAPON_SAWNOFFSHOTGUN",
  "WEAPON_CROWBAR",
  "WEAPON_HAMMER",
  "WEAPON_KNIFE",
  "WEAPON_MOLOTOV",
  "WEAPON_FLARE",
  "WEAPON_SNOWBALL",
  "WEAPON_WRENCH",
  "WEAPON_NIGHTSTICK",
}

Citizen.CreateThread(function()
	    while true do
		          Citizen.Wait(0)
		          local ped = PlayerPedId()
		          if DoesEntityExist( ped ) and not IsEntityDead( ped ) and not IsPedInAnyVehicle(PlayePedId(), true) then
			                loadAnimDict( "reaction@intimidation@1h" )
			                if CheckWeapon(ped) then
                                                       if holstered then
					                            TaskPlayAnim(ped, "reaction@intimidation@1h", "outro", 8.0, 2.0, -1, 48, 10, 0, 0, 0 )
					                            Citizen.Wait(600)
					                            ClearPedTasks( ped )
					                            holstered = false
				                      end
				                      SetPedComponentVariation( ped , 9, 0, 0, 0)
			                elseif not CheckWeapon(ped) then
				                      if not holstered then
					                            TaskPlayAnim(ped, "reaction@intimidation@1h", "intro", 8.0, 2.0, -1, 48, 10, 0, 0, 0 )
					                            Citizen.Wait(500)
					                            ClearPedTasks( ped )
					                            holstered = true
				                      end
				                      SetPedComponentVariation(ped, 9, 1, 0, 0)
			                end
                           end
             end
end)

function CheckWeapon(ped)
             for i = 1, #weapons do
		           if GetHashKey(weapons[i]) == GetSelectedPedWeapon(ped) then
			                 return true
		           end
	     end
             return false
end

function loadAnimDict( dict )
	     while ( not HasAnimDictLoaded( dict ) ) do
                          RequestAnimDict( dict )
		          Citizen.Wait( 0 )
	     end
end

I put it in code format and edited a few things that looked wrong to me

It’s this.

If you plan to keep trying to get the version you have to work. When you start the script hit F8 and tell us what the error is. I can’t exactly run the script from where I’m at right now. But if you just want the working version it is above.

I’m trying to get the gangster weapon draw animation to play for all players that pull out a weapon I seen the script used in TFRP and another server and it makes people rp over gunplay cause everyone will see you reaching for a weapon but I doubt those 2 severs are going to share that script with the fiveM community so I figured I would try to figure it out, I have a good Lua coding program that can debug and complie scripts but no enviorment to test them in

local holstered = true

local skins = {
  "mp_f_freemode_01",
  "mp_m_Freemode_01",
  }

local weapons = {
  "WEAPON_PISTOL",
  "WEAPON_COMBATPISTOL",
  "WEAPON_STUNGUN",
  "WEAPON_APPISTOL",
  "WEAPON_PISTOL50",
  "WEAPON_SNSPISTOL",
  "WEAPON_HEAVYPISTOL",
  "WEAPON_VINTAGEPISTOL",
  "WEAPON_FLAREGUN",
  "WEAPON_REVOLVER",
  "WEAPON_MINISMG",
  "WEAPON_SWITCHBLADE",
  "WEAPON_MACHETE",
  "WEAPON_KNUCKLE",
  "WEAPON_MARKSMANPISTOL",
  "WEAPON_HATCHET",
  "WEAPON_DAGGER",
  "WEAPON_BOTTLE",
  "WEAPON_BALL",
  "WEAPON_SMOKEGRENADE",
  "WEAPON_BZGAS",
  "WEAPON_MICROSMG",
  "WEAPON_SAWNOFFSHOTGUN",
  "WEAPON_CROWBAR",
  "WEAPON_HAMMER",
  "WEAPON_KNIFE",
  "WEAPON_MOLOTOV",
  "WEAPON_FLARE",
  "WEAPON_SNOWBALL",
  "WEAPON_WRENCH",
  "WEAPON_NIGHTSTICK",
}


Citizen.CreateThread(function()
	    while true do
		    Citizen.Wait(0)
		    local ped = PlayerPedId()
		    if DoesEntityExist( ped ) and not IsEntityDead( ped ) and not IsPedInAnyVehicle(PlayerPedId(), true) and CheckSkin(ped) then
                            loadAnimDict( "reaction@intimidation@1h" )
                            if CheckWeapon(ped) then
                                    if holstered then
					    TaskPlayAnim(ped, "reaction@intimidation@1h", "outro", 8.0, 2.0, -1, 48, 10, 0, 0, 0 )
					    Citizen.Wait(600)
					    ClearPedTasks( ped )
					    holstered = false
			            end
	                    elseif not CheckWeapon(ped) then
				    if not holstered then
					    TaskPlayAnim(ped, "reaction@intimidation@1h", "intro", 8.0, 2.0, -1, 48, 10, 0, 0, 0 )
					    Citizen.Wait(500)
					    ClearPedTasks( ped )
					    holstered = true
				    end
		            end
                    end
            end
end)

function CheckSkin (ped)
       for i = 1, #skins do
               if GetHashkey(skins[i]) == GetEntityModel(ped) then
                       return true
               end
       end
       return false
end

function CheckWeapon(ped)
       for i = 1, #weapons do
		           if GetHashKey(weapons[i]) == GetSelectedPedWeapon(ped) then
			                 return true
		           end
       end
       return false
end

function loadAnimDict( dict )
	     while ( not HasAnimDictLoaded( dict ) ) do
                           RequestAnimDict( dict )
		           Citizen.Wait( 0 )
	     end
end

ok I think this might work for mp model peds as the server I’m helping set this up for only has mp models it seems right if I think of it as what am’I trying to get the script to do but I’m not 100 sure

But why are you using

SetPedComponentVariation( ped , 9, 0, 0, 0)

Why put a vest on everybody when they have a weapon? Seems weird to me

I don’t know alot about scripting I’m looking at other scripts while trying to figure out how to get this one to work so I just remove both instances of the SetPedComponentVariation, I would like the animation to play when the script checks for the specified weapons and if the weapon is listed then after they release the Input_Select_Weapon it will play the animation showing them reaching into there back to draw the weapon and when they tab and put away a weapon listed in the script it plays the animation of them putting the weapon back, I might be trying to do something that is way beyond what someone starting out in Lua coding should be doing

did you ever had any sucess with this script?

not yet I have been refining the lua code it looks like it will work but atm I have no enviorment to test scripts I have a wierd router that it next to impossible to port forward and throw up a testing server