Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Play Animation when player pulls out tool not working?

Asked by 5 years ago

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:

01Amim = Instance.new("Animation")
02Amim.AnimationId = 04609133987
03Amin.Parent = script.Parent.Parent
04 
05if script.Parent.Parent.Activated == true then
06    Amim:play()
07end
08 
09if script.Parent.Parent.Deactivated == true then
10    Amim:stop()
11end

1 answer

Log in to vote
1
Answered by 5 years ago

The animations has priority, use "Movement" and disable loop. The script must be "local"

01local tool = script.Parent -- The tool that you're equipping
02local Amim = Instance.new("Animation") -- you forgot "local" in here
03Amim.AnimationId = 04609133987
04Amin.Parent = script.Parent.Parent
05 
06local player = game.Players.LocalPlayer -- identifies the player user, works only with local script
07local Humanoid = player.Character:WaitForChild(Humanoid) -- identifies humanoid for animation
08local track = Humanoid:LoadAnimation(anim) -- loads animation
09 
10tool.Equipped:Connect(function()
11track:play()
12end)
13tool.Unequipped:Connect(function()
14track:Stop()
15end)

To make animation work on equip you better use "Equipped:Connect()" You also have to load animation before playing it.

0
The script sits inside the Handle, it doesn't see, to work. Blxefirx 31 — 5y
0
put it outside the handle, or type in "local tool = script.Parent" this > "local tool = script.Parent.Parent" digameschannel 44 — 5y
Ad

Answer this question