How to Make a *POLISHED* Sprint and Stamina System in Roblox Studio (2023)

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 มิ.ย. 2024
  • In this video you'll learn how to create a sprint system with stamina and animations using character attributes!
    -- BIG ANNOUNCEMENT --
    My studio's game is nearing completion, but we need YOU to test the game and give feedback! By joining the Roblox group and Discord server, you'll gain access to unique rewards only given to testers!
    Game Link: www.roblox.com/games/15143143...
    Discord Server: / discord
    Group Link: www.roblox.com/groups/3325056...
    -- Timestamps --
    Intro 0:00
    Assigning Players Stats 0:06
    Setting up Input 2:19
    Setting up Stamina 4:15
    Setting up Stamina Recharge 6:02
    Creating the Stamina UI 9:05
    Stamina UI Script 10:57
    Adding Animations 12:49
    Stopping Player Movement 14:04
  • ยานยนต์และพาหนะ

ความคิดเห็น • 101

  • @ManlyCreator
    @ManlyCreator  5 หลายเดือนก่อน +12

    If if you enjoyed this video and want to support me then don't forget to try my game with the link in the description! I was trying a different style of video where I explain what I'm doing after doing it, so let me know in the replies what you thought of that and any questions you may have.

    • @tabimyers4257
      @tabimyers4257 5 หลายเดือนก่อน

      This is great!

    • @StillCode
      @StillCode 5 หลายเดือนก่อน

      On mobile the animation doesn’t work, also on pc whenever I use shift while standing the animation plays when I’m not moving. Other than that great video!

    • @misteryious
      @misteryious 5 หลายเดือนก่อน

      Great video, though when I implement the animation feature it doesn't work. And it doesn't show any red errors in the output about it..

    • @StillCode
      @StillCode 5 หลายเดือนก่อน

      @@misteryious his doesn’t work, so I made my own, when making put it on a loop or you’ll have to keep copy and pasting the animations

    • @coreyy2360
      @coreyy2360 4 หลายเดือนก่อน

      @@StillCodedownload RealismMod plugin, it has a ton of options including disable shiftlock

  • @elliotingberg3848
    @elliotingberg3848 2 หลายเดือนก่อน +1

    You should definitely keep doing these kinds of tutorials. You explaining what everything is doing actually makes me learn something!

  • @AlexSuperTV
    @AlexSuperTV 4 หลายเดือนก่อน +2

    Best tutorial ever! Thank you so much.

  • @Techie_Tac0
    @Techie_Tac0 หลายเดือนก่อน

    Bro this is an insane tutorial! Thank you so much for the help! You are a freaking legend! Definitely underated! I spent 2 hours tryna figure this out and i came across this vid! LIFESAVER!!

  • @theactualsplit
    @theactualsplit 3 หลายเดือนก่อน +9

    For the ppl that say they hold shift when they stay still and the animation still plays just put this under the print(stamina)
    if humanoid.MoveDirection.Magnitude

    • @SVNNYYT
      @SVNNYYT 2 หลายเดือนก่อน +1

      THANK YOU SO MUCH BRO YOU SAVED MY GAME

    • @ChiseledMango-rz8eb
      @ChiseledMango-rz8eb หลายเดือนก่อน +1

      Tysm

  • @Azderts
    @Azderts 26 วันที่ผ่านมา

    I’ve been trying to find a video where they show how to add walking and running animations separately, this video helped me

  • @user-qw8sw3lq8v
    @user-qw8sw3lq8v หลายเดือนก่อน

    trying to learn lua, great video explains everything and i can just copy what i dont get
    totally subbing

  • @SuperGotgames
    @SuperGotgames 25 วันที่ผ่านมา

    This is actually good replication techniques and a good tutorial compared to alot in the community nice work!

  • @Granite224
    @Granite224 4 หลายเดือนก่อน +6

    can you make the next vid about how to make a skill tree + skill points system (and levels if u want) (but only if u want to)

  • @EddieTheCreator
    @EddieTheCreator 3 หลายเดือนก่อน +1

    Thanks this video is super underrated now i can finally make a horror game

  • @elidbear6543
    @elidbear6543 15 วันที่ผ่านมา

    bro this helped me so much beascuase my code was right. but I didn't known you had to set the scale first.

  • @VeryProPlayerYesSir1122
    @VeryProPlayerYesSir1122 5 หลายเดือนก่อน +3

    18th like from me. Keep making good content sir.

  • @DraconianSG
    @DraconianSG 5 หลายเดือนก่อน +1

    10:29 you can fix that by changing the green bars anchor point, rotating ui in roblox causes issues sometimes and it’s unreliable

  • @Johnink03
    @Johnink03 5 หลายเดือนก่อน +4

    the legend is back

    • @ManlyCreator
      @ManlyCreator  5 หลายเดือนก่อน +2

      Haha thanks man, I hope you enjoy!

  • @zergiu3982
    @zergiu3982 4 หลายเดือนก่อน +1

    when i freeze while i run the runninganim is still going, how do i fix that?

  • @Darkchrome123
    @Darkchrome123 21 วันที่ผ่านมา

    I did everything exactly how it says, but im getting and error that says "Begin is not a valid member of Enum.UserInputType" at line 9

  • @BreezyEz-
    @BreezyEz- 4 หลายเดือนก่อน +2

    is there a way to when you sprint the FOV changes?

  • @BrainDeadOG
    @BrainDeadOG 12 วันที่ผ่านมา

    how would i change the remaining size to go right to left instead of up to down?

  • @T0m4t050up
    @T0m4t050up 4 วันที่ผ่านมา

    how do i make other actions take stamina as well? dashing or rolling for example

  • @LyleTrumble
    @LyleTrumble วันที่ผ่านมา

    hey your videos are really helpful. I have confronted a problem; when I run out of stamina completely it pauses for about 5 seconds before I start to regenerate stamina. Is there a solution for this problem?

  • @foxl_fc
    @foxl_fc 4 หลายเดือนก่อน

    i dont know why but when i press shift when i idle the animation play, how can i fix this?

  • @Firestarbright
    @Firestarbright 23 วันที่ผ่านมา

    When I press Shift it just makes me COMPLETLY stop and I cant walk anymore. I can only jump

  • @thatonechannel990
    @thatonechannel990 5 หลายเดือนก่อน +1

    sup dude its zeke w vidoe

    • @thatonechannel990
      @thatonechannel990 5 หลายเดือนก่อน +1

      should do a video doing a menu system like when a player presses M or a keybind a gui with like differant stuff it in

    • @ManlyCreator
      @ManlyCreator  5 หลายเดือนก่อน

      Yooo, thanks dude. A menu system is a good idea, I'll add that to my to-do list.

  • @HorizonX-YT
    @HorizonX-YT 3 หลายเดือนก่อน

    can you make the same thing but you also loose stamina when you jump?

  • @zquwuuu
    @zquwuuu 4 หลายเดือนก่อน

    bro if i hold shift when i say animation is playing how fix it?

  • @user-cy2yn5en2j
    @user-cy2yn5en2j 2 หลายเดือนก่อน

    bro iu stoped after 4 mins where u said test when i pressed shift i couldnt move at all i checked and everything was exactly the same i tried with r6 and r 15 none worked

  • @zsunya2
    @zsunya2 3 หลายเดือนก่อน

    Can you add a dashing system with this aswell?

  • @bad_code0191
    @bad_code0191 13 วันที่ผ่านมา

    what if I want stamina to decrease when I jump
    can anyone suggest me

  • @toothinm9paste
    @toothinm9paste 5 หลายเดือนก่อน

    for the character config, is it possible to add additional attributes for more options like, mana points, vitality points, for additional game mechanics?

    • @ManlyCreator
      @ManlyCreator  5 หลายเดือนก่อน

      Absolutely! Attributes are a very flexible way of controlling any kind of system you want to make.

  • @gemnmn
    @gemnmn 4 หลายเดือนก่อน

    How did you get animations of the marketplace? What?!

  • @thatonechannel990
    @thatonechannel990 5 หลายเดือนก่อน +1

    could you do a video on working on stuff 2d related like a 2 camera that works smoothly

    • @ManlyCreator
      @ManlyCreator  5 หลายเดือนก่อน

      That's a good idea. Just like a 2D platformer, right?

    • @thatonechannel990
      @thatonechannel990 5 หลายเดือนก่อน

      @@ManlyCreator yea since thats the type of game im maing

    • @ManlyCreator
      @ManlyCreator  5 หลายเดือนก่อน

      @@thatonechannel990 It might be a while before I make a video like that, but if you need it soon I'd recommend checking out my top-down camera video. All you need to do is change the camera angle and it would work the exact same 👍

  • @UsernameaBad
    @UsernameaBad 21 วันที่ผ่านมา

    How to make the stamina bar horizontal without it bugging out

  • @yoda7481
    @yoda7481 5 หลายเดือนก่อน

    I was wondering if it was possible to add wait(5) somewhere before it actually starts to recharge. Or make it so that once stamina reaches 50 or halway on the bar, it allows you to run again.

    • @mqte6759
      @mqte6759 4 หลายเดือนก่อน

      maybe u could add a timer before the stamina regen event starts

    • @MOLONTOP
      @MOLONTOP หลายเดือนก่อน

      yeah i did that for 2 seconds till recharge but i made it so you could still sprint even if 1 second had passed but it wouldn't regen ur stamina

  • @neroisntdead3681
    @neroisntdead3681 3 หลายเดือนก่อน

    Hey, im new to roblox studio, and this video is teaching me a lot, but for some reason, the game isnt applying the attributes to my character when I try testing it? I copied what you write letter for letter, but still nothing. Either way, again, thanks for the video!

    • @neroisntdead3681
      @neroisntdead3681 3 หลายเดือนก่อน

      Nevermind, I was checking the wrong file, it works for now!

  • @TheRealPaintist
    @TheRealPaintist 3 หลายเดือนก่อน

    W

  • @Slowezt
    @Slowezt 4 หลายเดือนก่อน

    why is my map uncolided i was falling forever

  • @toxomin9042
    @toxomin9042 5 หลายเดือนก่อน +2

    what happens to the stamina draining when you have different fps? do you drain more or less stamina depending on your fps

    • @ManlyCreator
      @ManlyCreator  5 หลายเดือนก่อน +3

      That's a really good question and I'm glad you brought that up. Players with a lower framerate would have a higher advantage since they would have less stamina subtracted each second. To fix this, use the equation (staminaUsage * 60 * delta) in place of just subtracting or adding staminaUsage. 60 assumes a base rate of 60 fps and delta is the time between each frame. Let's say a player's fps is 30, then the delta is going to be 0.03 (twice the delta of someone with 60 fps), therefore doubling the stamina used to balance out their usage with other players. Hope that makes sense.

    • @mrhekko9842
      @mrhekko9842 5 หลายเดือนก่อน

      That really feels like an ai generated response lol@@ManlyCreator

  • @ichirouyoosh2008
    @ichirouyoosh2008 หลายเดือนก่อน

    no model?

  • @AllSeeingDuo666
    @AllSeeingDuo666 4 หลายเดือนก่อน

    Can you make a version where the stamina bar only appears when your sprinting?

    • @HorizonX-YT
      @HorizonX-YT 3 หลายเดือนก่อน

      I'm not sure, but I think you can change the visibility or transparency of the gui or frames when the player is sprinting. I haven't tested this out, but you can try!

  • @TTTCozyy
    @TTTCozyy 4 หลายเดือนก่อน

    The player still sprints even when the leftShift button is released. It only stops when the stamina runs out. Same for the animation. Is there a way to fix this?
    The player won't play the animation too. Please help.
    Thank you.

    • @MOLONTOP
      @MOLONTOP 23 วันที่ผ่านมา

      you need input ended function,
      try this: UserInputService.InputEnded:connect(function(input)
      if input.keycode == enum.keycode.(your key)
      then character.Humanoid.WalkSpeed = "your base walkspeed"
      sprintanim(youranimation):stop()

  • @1245EK
    @1245EK 4 หลายเดือนก่อน +2

    For some reason the attributes wont add to the humanoid :/

  • @Lavonplayzku311
    @Lavonplayzku311 5 หลายเดือนก่อน

    Help when I was testing when I pressed shift my player stoped all I could do is jump and when I released shift it still wouldn’t move

    • @ManlyCreator
      @ManlyCreator  5 หลายเดือนก่อน

      Would you mind showing me your script?

    • @harikrishnatankala6141
      @harikrishnatankala6141 5 หลายเดือนก่อน

      problem started at 4:05 i am having the same problem and this is my script :
      character config:
      local module = {
      BaseWalkSpeed = 16,
      SprintSpeed = 32,
      Stamina = 100,
      MaxStamina = 100
      }
      return module
      player data:
      --Services--
      local RS = game.GetService("ReplicatedStorage")
      -- Settings--
      local characterConfig = require(RS.Configuration.CharacterConfig)
      --Script--
      game.Players.PlayerAdded:Connect(function(player)
      player.CharacterAdded:Connect(function(character)
      for stat, value in characterConfig do
      character.Humanoid:SetAttribute(stat, value)
      end
      end)
      end)
      SprintClient:
      --Services --
      local CAS = game:GetService("ContextActionService")
      --script--
      local character = script.Parent
      local humanoid = character:WaitForChild("Humanoid")
      local function sprint(actionName, inputState, inputType)
      if inputState == Enum.UserInputState.Begin then
      humanoid.WalkSpeed = humanoid:GetAttribute("SprintSpeed")
      elseif inputState == Enum.UserInputState.End then
      humanoid.WalkSpeed = humanoid:GetAttribute("BaseWalkSpeed")
      end
      end
      CAS:BindAction("Sprint", sprint, true, Enum.KeyCode.LeftShift )

    • @ziggykidder8861
      @ziggykidder8861 4 หลายเดือนก่อน +1

      if humanoid.MoveDirection.Magnitude

  • @8bitblox2
    @8bitblox2 5 หลายเดือนก่อน

    I cant move at all i can jump but thats it

  • @nexus1698
    @nexus1698 3 หลายเดือนก่อน

    how would i get the ui to fade off screen if im not sprinting

    • @MOLONTOP
      @MOLONTOP หลายเดือนก่อน

      i was trying to do that but i couldn't come up with a way to

  • @GalaxyNinjaX
    @GalaxyNinjaX 4 หลายเดือนก่อน +1

    I've copied everything exactly, but it won't work. why?

  • @mrhekko9842
    @mrhekko9842 5 หลายเดือนก่อน

    How do I make the make the user stop sprinting when he has stopped moving but still holding shift?

    • @ManlyCreator
      @ManlyCreator  5 หลายเดือนก่อน

      For this you would have to do constant checks with the RunService. If you join my Discord and contact me I can give you better assistance.

    • @ziggykidder8861
      @ziggykidder8861 4 หลายเดือนก่อน +1

      if humanoid.MoveDirection.Magnitude

    • @akeinSleeperbuild1278
      @akeinSleeperbuild1278 หลายเดือนก่อน +1

      ​@@ziggykidder8861 Thank god ur a life saver

  • @secretwolfninja
    @secretwolfninja 2 หลายเดือนก่อน

    why does it say walkspeed is not a valid member of humanoid? please help

    • @MOLONTOP
      @MOLONTOP 23 วันที่ผ่านมา

      it may be because u typed it wrong, in script its not walkspeed its WalkSpeed(with capitals) and its not humanoid its Humanoid

  • @-Miyoshi-
    @-Miyoshi- 5 หลายเดือนก่อน

    for some reason it wont work for me when i test at 4:13

    • @FrostyG15
      @FrostyG15 4 หลายเดือนก่อน

      Same

    • @jiggity2538
      @jiggity2538 2 หลายเดือนก่อน

      You must type humanoid.WalkSpeed with a uppercase S
      local function sprint(actionName, inputState, inputType)
      if inputState == Enum.UserInputState.Begin then
      humanoid.WalkSpeed = humanoid:GetAttribute("SprintSpeed")
      elseif inputState == Enum.UserInputState.End then
      humanoid.WalkSpeed = humanoid:GetAttribute("BaseWalkSpeed")
      end
      end
      This was my problem, idk about yours.

  • @ziggykidder8861
    @ziggykidder8861 4 หลายเดือนก่อน +2

    He did not show how to not make it so you dont play the anim while not moving so just add this in the SprintClient right before "Print(Stamina)"
    if humanoid.MoveDirection.Magnitude

    • @naistack
      @naistack 3 หลายเดือนก่อน

      goodlooks wouldn't have figured it out

    • @isaiassampaio2319
      @isaiassampaio2319 3 หลายเดือนก่อน

      Thank you so much, but now if I hold shift before moving the animation doesn't plays at all,
      It only plays if i'm already moving and then hold shift, any clues on fixing that?

  • @thecheeseclanwastaken
    @thecheeseclanwastaken 5 หลายเดือนก่อน +1

    How would i code the ui if I made it horizintal

    • @testdoang6161
      @testdoang6161 4 หลายเดือนก่อน +2

      humanoid:GetAttributeChangedSignal("stamina"):Connect(function()
      local stamina = humanoid:GetAttribute("stamina")
      remaining.Size = UDim2.new( (stamina / maxStamina), 0, 1, 0 )
      end)

    • @thecheeseclanwastaken
      @thecheeseclanwastaken 4 หลายเดือนก่อน

      thanks!@@testdoang6161

    • @theactualsplit
      @theactualsplit 3 หลายเดือนก่อน

      thx dawg ❤ @@testdoang6161

    • @Louisch1234
      @Louisch1234 2 หลายเดือนก่อน

      @@testdoang6161 Thx so much

  • @AppleCyder22
    @AppleCyder22 หลายเดือนก่อน

    i cant see it ( am i blind??)

  • @littlesonic5451
    @littlesonic5451 3 หลายเดือนก่อน

    why didnt it add the attributes? (i checked and everything was the same)

    • @SVNNYYT
      @SVNNYYT 2 หลายเดือนก่อน

      did you add the comas after the numbers in the module script?

    • @SVNNYYT
      @SVNNYYT 2 หลายเดือนก่อน

      1:57

    • @singusaustinite
      @singusaustinite หลายเดือนก่อน

      @@SVNNYYT i did but it still wouldnt work, any other solution?

  • @oBLXSSXDf
    @oBLXSSXDf หลายเดือนก่อน

    my stamina isnt draining

    • @oBLXSSXDf
      @oBLXSSXDf หลายเดือนก่อน

      nvm, I put :GetAttribute not :SetAttribute

  • @RushingAlt
    @RushingAlt 5 หลายเดือนก่อน +2

    YOUR studio 🤔🤔🤔

  • @ballsquare5
    @ballsquare5 หลายเดือนก่อน

    whenever i set the rechargeTime below 0.5 the stamina does not regen anymore, and i want to make the stamina regen slower, any help?