I have a punch tool that works entirely except when I use a randomized starter character. I have a script that chooses a random startercharacter from server storage, but when the tool is being used by one of these characters it does not load the attack animations and gives me an error message in output: “LoadAnimation requires the Humanoid object (boilinglogan8765432.Humanoid) to be a descendant of the game object”
What is the problem here and how might I be able to fix it?
The random character script:
while wait(0.5) do
local GenRand = math.random(1,3)
if GenRand == 1 then
game.StarterPlayer:FindFirstChild("StarterCharacter"):Destroy()
game.ServerStorage.Char1.StarterCharacter:Clone().Parent = game.StarterPlayer
elseif GenRand == 2 then
game.StarterPlayer:FindFirstChild("StarterCharacter"):Destroy()
game.ServerStorage.Char2.StarterCharacter:Clone().Parent = game.StarterPlayer
elseif GenRand == 3 then
game.StarterPlayer:FindFirstChild("StarterCharacter"):Destroy()
game.ServerStorage.Char4.StarterCharacter:Clone().Parent = game.StarterPlayer
end
end
the tool script:
local humanoid = char:WaitForChild("Humanoid")
local Holding = script:WaitForChild("Holding")
local anim = script:WaitForChild("Punch")
local anim1 = script:WaitForChild("PunchReady1")
local anim2 = script:WaitForChild("PunchLaunch")
local anim3 = script:WaitForChild("PunchHold")
local Punchdo = humanoid:LoadAnimation(anim)
local PunchReady = humanoid:LoadAnimation(anim1)
local PunchLaunch = humanoid:LoadAnimation(anim2)
local PunchHold = humanoid:LoadAnimation(anim3)
local debounce = false
script.Parent.Activated:Connect(function()
if debounce == true then
return
end
Holding.Value = true
PunchReady:Play()
PunchReady.Stopped:Wait()
PunchHold:Play()
end)
script.Parent.Deactivated:Connect(function()
if debounce == true then
return
end
debounce = true
Holding.Value = false
PunchHold:Stop()
PunchLaunch:Play()
wait (2)
debounce = false
end)

local humanoid = char:WaitForChild("Humanoid") is better to use because if the humanoid isnt loaded yet, the script will wait until the humanoid is loaded. And the humanoid wont return nil so yea
Try using this code for your tool script (just a few changes were made):
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local anim = script:WaitForChild("Punch")
local anim1 = script:WaitForChild("PunchReady1")
local anim2 = script:WaitForChild("PunchLaunch")
local anim3 = script:WaitForChild("PunchHold")
local Punchdo = hum:LoadAnimation(anim)
local PunchReady = hum:LoadAnimation(anim1)
local PunchLaunch = hum:LoadAnimation(anim2)
local PunchHold = hum:LoadAnimation(anim3)
local debounce = false
script.Parent.Activated:Connect(function()
if debounce == true then
return
end
Holding.Value = true
PunchReady:Play()
PunchReady.Stopped:Wait()
PunchHold:Play()
end)
script.Parent.Deactivated:Connect(function()
if debounce == true then
return
end
debounce = true
Holding.Value = false
PunchHold:Stop()
PunchLaunch:Play()
wait(2)
debounce = false
end)
Now it’s having the error I had before and “Players.boilinglogan8765432.Backpack.BabyNinjaTime Fist.LocalScript:11: attempt to index nil with ‘LoadAnimation’”
hmm… Do you really need a local script for playing the animations? I think it would be better if you’d do this on a (server) Script instead of a LocalScript.
Ive had this type of issue before. I was trying to play animations on a local script, and it gave me that error (thats said in the topic name). But I fixed it by playing the animations on a server script.
So no, i dont think it has anything to do with the animations themselves.