✓ Accepted answer
This one should work V
local Tool = script.Parent
local Player = game.Players.LocalPlayer
Tool.Activated:Connect(function()
local animTrack = Player.Character.Humanoid:LoadAnimation(script.Parent.Animation)
animTrack:Play()
end)
You forgot to index character. Humanoids are not parented to player objects. You can also find character by getting Tool's parent.
Humanoid:LoadAnimation() is deprecated by the way, you probably should use Animator:LoadAnimation() instead. (Animator is parented to Humanoid by default)
:connect() is also deprecated. I doubt there's any difference to be honest. The new one is :Connect(). Just so you know.
local Tool = script.Parent
local Player = game.Players.LocalPlayer
Tool.Activated:Connect(function()
local Character = Tool.Parent
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid ~= nil then
local animTrack = Humanoid.Animator:LoadAnimation(script.Parent.Animation)
animTrack:Play()
end
end)
1 comment
Sorry it didnt work