So, I got this script ready, but the problem is that I run it, it works without giving an error, but as soon as I aim with a sniper ID 34, it gives this error message, I don't understand much about scripting so I don't know how to solve it or what could it be, can anyone help me?
OBS: it's a script so that when the PLAYER aims with the sniper, it changes dimensions, to be correcting the problem of the weapon appearing in front of the scope if you aim too fast.
local alpha = 255
bindKey ( "aim_weapon", "both", function ( _, state )
if getPedWeaponSlot ( localPlayer ) == 6 then
if ( state == "down" ) then
alpha = 0
elseif ( state == "up" ) then
alpha = 255
end
for _, v in ipairs ( getElementsByType ( "object", root, true ) ) do
if isElementAttachedToBone ( v ) then
local id = getElementModel ( v )
if ( id == 2584 ) then
setElementAlpha ( v, alpha )
setElementDimension(v, alpha == 0 and 9999 or getElementDimension(localPlayer))
end
end
end
end
end )
PICTURE OF BUG
PICTURE OF BUG 2