I am trying to make it so if you Activate the tool it plays an animation but I get an error saying:Play is not a valid member of Animation “Animation”. I don’t know what to do. Here is my code:
local tool = script.Parent
tool.Activated:Connect(function()
local Anim = Instance.new("Animation")
Anim.AnimationId = "http://www.roblox.com/asset/?id=6852622094"
Anim:Play()
end)
Animation objects do not have a Play() function, that’s only referenced inside the Animator:LoadAnimation()/Humanoid:LoadAnimation()
And you never exactly loaded the animation, you have to reference either the Character’s Humanoid or Animator object (Preferably the Animator)
Try this:
local tool = script.Parent
tool.Activated:Connect(function()
local Character = tool.Parent
local Anim = Instance.new("Animation")
Anim.AnimationId = "http://www.roblox.com/asset/?id=6852622094"
local LoadAnim = Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(Anim)
LoadAnim:Play()
end)
3 Likes