How do I make a Fully Functional sprint (no stamina)

  1. I want to make a sprint with animation that works

  2. I’ve tried different sprint scripts and hours making my own, and all of them had issues

The main issue is animation. What I mean by that is if you press the shift key without moving the animation plays, and you run in place

How do I fix this?

1 Like

You could check the Humanoid’s State for “Running”

Didn’t work and the error messages either don’t show up or don’t make sense to me

humanoid.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Running then
print (“Player is running”)
end
end)

This is the script I used

Just check if the player’s movedirection is not 0,0,0/vector3.new()?

this video covers most of what u need

1 Like

Try this out should work fine

Localscript >> StarterPlayer >> CharacterScripts

local input = false
local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(key)
   if key.KeyCode == Enum.KeyCode.LeftShift then
       print("Is running")
       if input == true then return end
       input = true
       game.ReplicatedStorage.Run:FireServer("run")
   end
end)

uis.InputEnded:Connect(function(key)
   if key.KeyCode == Enum.KeyCode.LeftShift then
      input = false
      game.ReplicatedStorage.Run:FireServer("walk")
   end
end)

Script >> ServerScriptService

game.ReplicatedStorage.Run.OnServerEvent:Connect(function(plr, inptype)
   if not workspace:FindFirstChild(plr.Name) then return end
   if inptype == "run" then
      workspace[plr.Name].Humanoid.WalkSpeed = 35
   end
   if inptype == "walk" then
      workspace[plr.Name].Humanoid.WalkSpeed = 16
   end
end)

Sorry i didn’t have an explanation of how it works since i’m on a phone and i’m used to using my pc.

Edit: Add a remoteevent in Replicatedstorage and name it “Run”

2 Likes

“Run is not a valid member of Replicated Storage”?

2 Likes

Add a remoteevent in replicatedstorage and name it “Run”

1 Like

Thank you so much omg

You saved my sanity, now I just add an animation

1 Like

You can use Humanoid:LoadAnimation(animationinstance) for animations and it should work all fine! :happy3:

1 Like

cough cough may I ask how?

This my first game pls no bully :worried:

1 Like

it’s all fine i also recommend watching @Alvin_Blox’s scripting tutorials they are really helpful. anyways go in the part where it changes walkspeed to 35 and add a new line and type this

local character = workspace[plr.Name]
local animation = Instance.new("Animation")
local animationid = type animation id here
animation.AnimationId = "rbxassstid://"..animationid
character.Humanoid:LoadAnimation(animation)
1 Like

Also if it matters in your game, you should make checks where needed if they are allowed to sprint or not. As the above script example stands, exploiters can send “run” regardless if they are pressing shift or not, effictively giving them infinite “run” time.

2 Likes

Thank you, and I saw most of alvins videos I plan on finishing his scripting tutorial tomorrow

1 Like

Hello peanut brain is back, I hate to annoy you but…

game.ReplicatedStorage.Run.OnServerEvent:Connect(function(plr, inptype)
   if not workspace:FindFirstChild(plr.Name) then return end
   if inptype == "run" then
		      workspace[plr.Name].Humanoid.WalkSpeed = 35
		local character = workspace[plr.Name]
local animation = Instance.new("Animation")
local animationid = type animation id here
animation.AnimationId = "rbxassstid://5356324783"..animationid
character.Humanoid:LoadAnimation(animation)
   end
   if inptype == "walk" then
      workspace[plr.Name].Humanoid.WalkSpeed = 16
   end
end)

I want to know want i’m doing wrong. I will learn from mistakes

1 Like

At the local animationid = blah blah, change the text inside to get your animationid by publishing the animation

Expected identifier when parsing expression got (my animation id here)

at .animationid you should remove the id from the object but add it in the animationid variable

local animationid = type 5356324783
animation.AnimationId = "rbxassstid://5356324783"..5356324783
character.Humanoid:LoadAnimation(animation)