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

How would I make the animation work for my sprint script?

Asked by
FBS_8 25
5 years ago
Edited 5 years ago

I have tried to add an animation when sprinting to my script but it doesn't seem to work, the output says: "Stop is not a valid member of animation"

01local anim = script.RunAnim
02repeat wait() until script.Parent.Name == "Backpack"
03script.KeyDown.OnServerEvent:Connect(function(asd,yo)
04    if yo == "0" then
05        script.Parent.Parent.Character.Humanoid.WalkSpeed = 20
06        anim:Play()
07    end
08end)
09script.KeyUp.OnServerEvent:Connect(function(asd,yo)
10    if yo == "0" then
11        script.Parent.Parent.Character.Humanoid.WalkSpeed = 13
12        anim:Stop()
13    end
14end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Okay, a lot of mistakes but I'll help you out.

Make a local script (Client script), put inside the animation (named RunAnim),put it in the starter pack and write the following:

01local UIS = game:GetService("UserInputService")
02local p = game:GetService("Players").LocalPlayer
03local = p.Character or p.CharacterAdded:Wait()
04local anim = script.RunAnim
05local RunAnimation = c:WaitForChild("Humanoid"):LoadAnimation(anim)
06UIS.InputBegan:Connect(function(i,a)
07    if not a then
08        if i.KeyCode == Enum.KeyCode.LeftShift then
09            c:WaitForChild("Humanoid").WalkSpeed = 20
10            RunAnimation:Play()
11        end
12    end
13end)
14 
15UIS.InputEnded:Connect(function(i,a)
View all 22 lines...
0
Works thx FBS_8 25 — 5y
Ad

Answer this question