I have a LocalScript inside a knife tool that I made. The script is supposed to play an equip animation when the knife is equipped, but it isn’t working…
This is the code:
local knife = script.Parent --here we got the knife tool
local pla = game.Players.LocalPlayer --here we got the player
local cha = pla.Character or pla.CharacterAdded:Wait() --here we got the character from the player
local hum = cha:WaitForChild("Humanoid")--here we got the humanoid from the character
if hum then
local animation = Instance.new("Animation") --here we create a new animation
animation.Parent = script.Parent --here we put the new animation inside the knife tool
animation.AnimationId = "rbxassetid://6892348505" --put your animation id here
local animator = Instance.new("Animator")
if animator then
local animTrack = animator:LoadAnimation(animation) --here we load the animation
end
end
knife.Equipped:Connect(function() --here we make the animation play when we equip the knife
animTrack:Play() --here the animation plays
end)
knife.Unequipped:Connect(function() --here we make the animation stop when unequipped
animTrack:Stop() --here the animation stops
end)
Where exactly is animator parented to? That could be the issue. (I noticed you don’t have it parented at all, you simply instanced it but you never set it to anything.)