Hello, I made a complicated gun tool, so posting the entire script here will give you a headache.
My issue is that whenever I get the tool via script, the tool wont play the idle animation or do the actions the gun supposed to do. I tried to check if the script even detects whenever I equip it - it doesn't.
local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local gun = plr.Backpack:WaitForChild("M1A1") --gun name
local animations = gun.Animations
local idleTrack = hum:LoadAnimation(animations.Idle)
gunEquipped = false
--Functions
function equip()
if not gunEquipped then
idleTrack:Play()
gunEquipped = true
uis.MouseIconEnabled = false
end
end
function unequip()
if gunEquipped then
idleTrack:Stop()
gunEquipped = false
uis.MouseIconEnabled = true
end
end
--Events
gun.Equipped:Connect(function()
equip()
end)
gun.Unequipped:Connect(function()
unequip()
end)
The script above would work only if the gun was in StarterPack when I play the game, but it I try to parent it manually to the Backpack (via script or picking the gun up) the gun just wont work, its scripts dont work, I just hold the gun model and thats it.
Did anyone encounter this issue? How do I solve this?

2 comments
Are there any errors? Can you show the rest of the script, such as where gun is defined?
No there are no errors, whenever I get the tool with a script (I want to make a loadout system that gives you the gun) the tool just wont work. I just hold it but no animations, no actions, nothing. I edited my question thats a more detailed script