Hello, I was trying to make an Animation script that plays when a player pulls out a tool. I'm most likely to be using the wrong events.
Code:
Amim = Instance.new("Animation") Amim.AnimationId = 04609133987 Amin.Parent = script.Parent.Parent if script.Parent.Parent.Activated == true then Amim:play() end if script.Parent.Parent.Deactivated == true then Amim:stop() end
The animations has priority, use "Movement" and disable loop. The script must be "local"
local tool = script.Parent -- The tool that you're equipping local Amim = Instance.new("Animation") -- you forgot "local" in here Amim.AnimationId = 04609133987 Amin.Parent = script.Parent.Parent local player = game.Players.LocalPlayer -- identifies the player user, works only with local script local Humanoid = player.Character:WaitForChild(Humanoid) -- identifies humanoid for animation local track = Humanoid:LoadAnimation(anim) -- loads animation tool.Equipped:Connect(function() track:play() end) tool.Unequipped:Connect(function() track:Stop() end)
To make animation work on equip you better use "Equipped:Connect()" You also have to load animation before playing it.