hello i’m making a simple gun with the body attach for 100% animated tool when i first spawn its working fine but when i die it says
LoadAnimation requires the Humanoid object (322ita.Humanoid) to be a descendant of the game object
here is the script
local canshoot = true
local isreloading = false
local noammotime = true
local holding = false
local canreload = true
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local tool = script.Parent
local actionService = game:GetService("ContextActionService")
local hum
local shootEff
local equipeff
local reloadeff
local emptyeff
local variables
local ammo
local reserveammo
local magsize
local playerGui
local show_ammo
local idleAnim
local shootAnim
local reloadAnim
local emptyanim
local function reload()
if canreload ==true and holding == true and isreloading == false and reserveammo.Value > 30 and ammo.Value < 30 then
local needed = magsize.Value - ammo.Value
wait()
isreloading = true
canreload = false
reloadAnim:Play()
reloadeff:Play()
wait(3)
isreloading = false
ammo.Value = magsize.Value
wait()
reserveammo.Value = reserveammo.Value - needed
canreload = true
elseif canreload ==true and reserveammo.Value < 30 or reserveammo.Value == 30 and holding == true and isreloading == false and ammo.Value < 30 then
local needed = ammo.Value + reserveammo.Value
wait()
isreloading = true
canreload = false
reloadAnim:Play()
reloadeff:Play()
wait(3)
isreloading = false
ammo.Value = ammo.Value + needed
wait()
reserveammo.Value = reserveammo.Value - needed
canreload = true
elseif reserveammo.Value < 0 then
canreload = false
end
end
tool.Equipped:Connect(function()
hum = char:WaitForChild("Humanoid")
shootEff = tool:WaitForChild("Hole"):WaitForChild("shoot")
equipeff = tool:WaitForChild("Hole"):WaitForChild("Equip sound")
reloadeff = tool:WaitForChild("Hole"):WaitForChild("Reload Sound")
emptyeff = tool:WaitForChild("Hole"):WaitForChild("EmptySound")
variables = tool:WaitForChild("VALues")
ammo = variables:WaitForChild("ammo")
reserveammo = variables:WaitForChild("reserveammo")
magsize = variables:WaitForChild("MagSize")
playerGui = plr:WaitForChild("PlayerGui")
show_ammo = playerGui:WaitForChild("show ammo")
idleAnim = hum:LoadAnimation(script:WaitForChild("Hold"))
shootAnim = hum:LoadAnimation(script:WaitForChild("Recoil"))
reloadAnim = hum:LoadAnimation(script:WaitForChild("Reload"))
emptyanim = hum:LoadAnimation(script:WaitForChild("empty"))
show_ammo.Enabled = true
actionService:BindAction("Reload", reload, true, Enum.KeyCode.R)
actionService:SetPosition("Reload", UDim2.new(0.58, 0,0.15, 0))
actionService:SetTitle("Reload", "reload")
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = "http://www.roblox.com/asset?id=117431027"
game.ReplicatedStorage.ConnectM6D:FireServer(tool.BodyAttach)
char.UpperTorso.ToolGrip.Part0 = char.UpperTorso
char.UpperTorso.ToolGrip.Part1 = tool.BodyAttach
idleAnim:Play()
equipeff:Play()
holding = true
while wait() do
show_ammo.TextLabel.Text = "ammo: "..ammo.Value.."/ "..reserveammo.Value
end
end)
tool.Unequipped:Connect(function()
show_ammo.Enabled = false
actionService:UnbindAction("Reload")
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = "http://www.roblox.com/asset?id=5801470647"
game.ReplicatedStorage.DisconnectM6D:FireServer()
idleAnim:Stop()
equipeff:Play()
holding = false
end)
tool.Activated:Connect(function()
if isreloading == false and ammo.Value > 0 and canshoot == true then
wait()
ammo.Value = ammo.Value - 1
canshoot = false
shootAnim:Play()
shootEff:Play()
wait(1)
canshoot = true
elseif ammo.Value == 0 and noammotime == true then
local playerGui = plr:WaitForChild("PlayerGui")
playerGui["no ammo"].Enabled = true
noammotime = false
emptyeff:Play()
emptyanim:Play()
wait(3)
noammotime = true
playerGui["no ammo"].Enabled = false
end
end)
i’ve already did some reserach but i didnt find any fix can some one help me?

