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

Animation tool won't work, why?

So I have a food tool with bricks and I have a local script inside the tool. Inside the local script I have this code:

function Eat()
local humanoid = game.Players:getPlayerFromCharacter()
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=275381821" -- your id here
local animTrack = humanoid:LoadAnimation(animation) -- chanhe Humanoid to the target's Humanoid
animTrack:Play()
end

script.Parent.Equipped:connect(function(click)
local humanoid = game.Players.LocalPlayer
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=275382695" -- your id here
local animTrack = humanoid:LoadAnimation(animation) -- chanhe Humanoid to the target's Humanoid
animTrack:Play()
end)

script.Parent.Equipped:connect(function(click)
	script.Parent.Button1Down:connect(Eat)
end)



It won't work? It's supposed to hold up both hands when equipped(looped animation of two hands up) and when you click it should play the eating animation but it doesn't.

Here is the output for the second paragraph of code: 16:59:57.794 - LoadAnimation is not a valid member of Player 16:59:57.795 - Script 'Workspace.Player1.Noodle Soup.Anim', Line 13 16:59:57.796 - Stack End

Here is the output for the 3rd paragraph of code: 16:59:57.790 - Button1Down is not a valid member of Tool 16:59:57.791 - Script 'Workspace.Player1.Noodle Soup.Anim', Line 18 16:59:57.792 - Stack End

2 answers

line 10 should be local humanoid = game.Players.LocalPlayer.Character.Humanoid

Instead of using Button1Down, use Activated:

script.Parent.Activated:connect(function()

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