Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Getting a animation error when resetting if holding a tool? (SOLVED BY ME)

Everytime i reset holding this tool in the output gives me this error:

LoadAnimation requires the Humanoid object (sebanuevo.Humanoid) to be a descendant of the game object

My local script:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local dirt = script.Parent.Handle.CurrentDirt
local tool = script.Parent
local a = script.Parent.Handle.anim
animation = char:WaitForChild("Humanoid"):LoadAnimation(a)

tool.Activated:Connect(function() 
	animation:Play()
	if dirt.Value ~= nil then
		local yes = dirt.Value["Dirt "].Decal
		game.ReplicatedStorage.YeS:FireServer(yes)
	end
end)

2 answers

Strange. Do this instead:

local humanoid = char:WaitForChild("Humanoid")
local animation = humanoid:LoadAnimation(a)

If it's helpful, remember to accept the answer :D I'm glad to help!

2 comments

0

Didn't work, you are still doing the same thing

0

Even though it looks like the same thing, you still gotta try, strange things happen all time. Honestly I don't have a clue about the problem.

I tried this and it worked:

local plr = game.Players.LocalPlayer
local dirt = script.Parent.Handle.CurrentDirt
local tool = script.Parent
local a = script.Parent.Handle.anim

tool.Activated:Connect(function() 
	local char = tool.Parent
	local humanoid = char:WaitForChild("Humanoid")
	local animation = humanoid:LoadAnimation(a)
	animation:Play()
	if dirt.Value ~= nil then
		local yes = dirt.Value["Dirt "].Decal
		game.ReplicatedStorage.YeS:FireServer(yes)
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.