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

Why Is The Weapon Hold Animation Playing When I Unequip The Weapon? [UNSOLVED]

Asked by 1 year ago

I am making a zombie game with custom guns and animations made by me the animations play just fine but I’m having trouble scripting when the animations actually play this is my first time making and scripting animations here is my code, Thanks:

001local player = game:GetService('Players').LocalPlayer
002 
003local character = player:FindFirstChild('Character')
004 
005if not character or not character.Parent then
006 
007character = player.CharacterAdded:Wait()
008 
009end
010 
011local humanoid = character:WaitForChild("Humanoid")
012 
013local animator = humanoid:WaitForChild("Animator")
014 
015HoldHK33.OnClientEvent:Connect(function()
View all 135 lines...

Whenever I unequip the gun the hold animation and the crosshair appear as if I still have the tool equipped, Thanks.

1 answer

Log in to vote
1
Answered by
KingDomas 153
1 year ago

There should be a few tutorials of this on youtube.

01--Here's a quick script I found (not mine!):
02local tool = script.Parent
03local anim = Instance.new("Animation")
04anim.AnimationId = "http://www.roblox.com/Asset?ID=8333681071" --Animation ID
05local track
06tool.Equipped:Connect(function()
07    track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
08    track.Priority = Enum.AnimationPriority.Action
09    track.Looped = true
10    track:Play()
11end)
12 
13tool.Unequipped:Connect(function()
14    if track then
15        track:Stop()
16    end
17end)
Ad

Answer this question