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"
01 | local anim = script.RunAnim |
02 | repeat wait() until script.Parent.Name = = "Backpack" |
03 | script.KeyDown.OnServerEvent:Connect( function (asd,yo) |
04 | if yo = = "0" then |
05 | script.Parent.Parent.Character.Humanoid.WalkSpeed = 20 |
06 | anim:Play() |
07 | end |
08 | end ) |
09 | script.KeyUp.OnServerEvent:Connect( function (asd,yo) |
10 | if yo = = "0" then |
11 | script.Parent.Parent.Character.Humanoid.WalkSpeed = 13 |
12 | anim:Stop() |
13 | end |
14 | end ) |
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:
01 | local UIS = game:GetService( "UserInputService" ) |
02 | local p = game:GetService( "Players" ).LocalPlayer |
03 | local c = p.Character or p.CharacterAdded:Wait() |
04 | local anim = script.RunAnim |
05 | local RunAnimation = c:WaitForChild( "Humanoid" ):LoadAnimation(anim) |
06 | UIS.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 |
13 | end ) |
14 |
15 | UIS.InputEnded:Connect( function (i,a) |