i am making a simulator game so i made a tool and it can load an animation but i cant stop it. my script might look dumb but im still a beginner scripter:
script.Parent.Equipped:Connect(function() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0 animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Hold) animation:Play() end) script.Parent.Unequipped:Connect(function() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Hold) animation:Stop() end)
that last part i cant stop the animation
btw i named the animation hold because im holding a tool
What I do when i encounter this problem, is create a separate animation and i name it "security", which basically stops all animations.
Tutorial
First, load in your animation editor onto a rig... thing
Then, you basically disable all of the parts ( Can be done by clicking every single box to the left of your editor )
So finally, you just add that animation onto your tool (or whatever)
Final code:
script.Parent.Equipped:Connect(function() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0 animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Hold) animation:Play() end) script.Parent.Unequipped:Connect(function() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 animation =game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Hold) animation:Stop() ----ADDED CODE SecurityAn = (Ur animation) SecurityAn:Play wait(0.5) SecurityAn:Stop() end)
Hope this was clear :)
Simple solution! Just use the unequipped function like for example:
Script.Parent.Unequipped:Connect(function()
So your solution is:
Script.Parent.Unequipped:Connect(function() -- Does a function on tool unequipped. animation:Stop() -- Stops the animation.
Make sure you put that under all that line of code! It should work. If you want to make it do anything else on unequipped, then just simply put what you want to do under the unequipped event like this:
Script.Parent.Unequipped:Connect(function() -- Put whatever you want to make the tool do on unequipped here.