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"
local anim = script.RunAnim repeat wait() until script.Parent.Name == "Backpack" script.KeyDown.OnServerEvent:Connect(function(asd,yo) if yo == "0" then script.Parent.Parent.Character.Humanoid.WalkSpeed = 20 anim:Play() end end) script.KeyUp.OnServerEvent:Connect(function(asd,yo) if yo == "0" then script.Parent.Parent.Character.Humanoid.WalkSpeed = 13 anim:Stop() end 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:
local UIS = game:GetService("UserInputService") local p = game:GetService("Players").LocalPlayer local c = p.Character or p.CharacterAdded:Wait() local anim = script.RunAnim local RunAnimation = c:WaitForChild("Humanoid"):LoadAnimation(anim) UIS.InputBegan:Connect(function(i,a) if not a then if i.KeyCode == Enum.KeyCode.LeftShift then c:WaitForChild("Humanoid").WalkSpeed = 20 RunAnimation:Play() end end end) UIS.InputEnded:Connect(function(i,a) if not a then if i.KeyCode == Enum.KeyCode.LeftShift then c:WaitForChild("Humanoid").WalkSpeed = 13 RunAnimation:Stop() end end end)