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.
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!
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
for anyone who wants the jump animation to play while sprinting try this humanoid.StateChanged:Connect(function(oldState, newState) if newState == Enum.HumanoidStateType.Jumping then if sprintAnim then sprintAnim:Stop() end end end) humanoid.StateChanged:Connect(function(oldState, newState) if newState == Enum.HumanoidStateType.Landed and isSprinting then if sprintAnim then sprintAnim:Play() end end end)
one issue, is that with runservice, the speed changes depending on the player fps, since more frames are rendered, I think a simple way to fix it is the have a "while true do wait(1/60) end" loop, might not be the prettiest but it gives a more consistent stamina.
Hey man, I'm new to coding. I've been trying to find out where to change the runservice but every time I edit it. For some reason the stamina doesn't work. Can you tell me where to change it. Thank you
@@trollersupreme4316 there's the function that the run service activates, all the code inside of that, put it inside the while true do wait(1/60) *put the code here* end
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
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?
hey i dont know if he didnt show this but my stamina doesnt regen it goes down then doesnt regen then i cant run no more heres my script -- Script -- local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local maxStamina = humanoid:GetAttribute("MaxStamina") local screen = script.Parent local staminaBar = screen:WaitForChild("StaminaBar") local remaining = staminaBar:WaitForChild("Remaining") humanoid:GetAttributeChangedSignal("Stamina"):Connect(function() local stamina = humanoid:GetAttribute("Stamina") remaining.Size = UDim2.new(1, 0, 1 - (1- (stamina / maxStamina))) end)
this is kind of late but for some reason it doesn’t apply the attributes. i have everything copied word for word yet it still doesn’t let me sprint use stamina etc
just fyi at 12:32 the 1 - (1 - Stamina/MaxStamina) is redundant, all you need is Stamina/MaxStamina (because we want the percentage out of 1, which that already is! :) thanks so much for the tutorial
I finished everything and the sprint works and stamina but when I start sprinting stand still while still holding shift and run again it doesn't play the animation
Copy and paste this into the sprint Client in starter character scripts: "-- Services -- local CAS = game:GetService("ContextActionService") local RNS = game:GetService("RunService") -- Settings -- local StaminaUsage = 0.5 -- How much stamina to use while running local RechargeTime = 1 -- How long until stamina starts recharging -- Script -- local character = script.Parent local humanoid = character:WaitForChild("Humanoid") -- Animation -- local Sprint = script.Sprint local SprintAnim = humanoid.Animator:LoadAnimation(Sprint) local LastSprint = math.huge local IsSprinting = false local function sprint(actionName, inputState, inputType) if inputState == Enum.UserInputState.Begin then IsSprinting = true elseif inputState == Enum.UserInputState.End then IsSprinting = false end
if humanoid.WalkSpeed 0 and humanoid.MoveDirection.Magnitude > 0 and humanoid.WalkSpeed > 0 then humanoid:SetAttribute("Stamina", stamina - StaminaUsage) LastSprint = tick() else if tick() - LastSprint >= RechargeTime and stamina < humanoid:GetAttribute("MaxStamina") then humanoid:SetAttribute("Stamina", stamina + StaminaUsage) end end print(humanoid:GetAttribute("Stamina")) if humanoid.MoveDirection.Magnitude
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!!
7:19 I got to this point where everything stopped working. I've gone through all of my code multiple times and I haven't found where the problem is coming from, but I'm completely unable to sprint. My current script: -- Services -- local CAS = game:GetService("ContextActionService") local RNS = game:GetServivce("deltaTime") -- Settings -- local staminaUsage = 0.5 local rechargeTime = 1 -- Script -- local character = script.Parent local humanoid = character:WaitForChild("Humanoid") local lastSprint = math.huge local isSprinting = false local function sprint(actionName, inputState, inputType) if inputState == Enum.UserInputState.Begin then isSprinting = true elseif inputState == Enum.UserInputState.End then isSprinting = false end
if isSprinting then humanoid.WalkSpeed = humanoid:GetAttribute("SprintSpeed") else humanoid.WalkSpeed = humanoid:GetAttribute("BaseWalkSpeed") end end CAS:BindAction("Sprint", sprint, true, Enum.KeyCode.LeftShift) RNS.RenderStepped:Connect(function(delta) local stamina = humanoid:GetAttribute("Stamina") if isSprinting then humanoid:SetAttribute("Stamina", stamina - staminaUsage) lastSprint = tick() else if tick() - lastSprint >= rechargeTime and stamina < humanoid:GetAttribute("MaxStamina") then humanoid:SetAttribute("Stamina", stamina + staminaUsage) end end print(stamina) end)
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.
for i = 1,5 do game.Workspace.CurrentCamera.FieldOfView = (110+(i*2)) task.wait() humanoid.WalkSpeed = humanoid:GetAttribute("SprintSpeed") end wait() else sprintAnim:Stop() humanoid.WalkSpeed = humanoid:GetAttribute("BaseWalkSpeed") for i = 1,5 do game.Workspace.CurrentCamera.FieldOfView = (110-(i*1.5)) wait(0.00001) put this in there the wait at the end with 0.00001 is not vital but it putted there for funsies and the task.wait() is so that the player cant spam shift and get inf stamina and the fov is dictated by the place where 110 is at make sure they are both even because if so it won't decrease or increase after you unhold shift
So ive run into the problem that after the stamina id implemented the sprint speed is immediately cut, the stamina still works but sprint speed dies for spme reason
if it subtracts stamina by 0.5 every frame, wouldnt that mean that someone on 30 fps would be able to sprint for longer than someone on 120? I may be stupid but i just want to make sure... kinda new to all of this stuff.
@@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 👍
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?
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.
for the character config, is it possible to add additional attributes for more options like, mana points, vitality points, for additional game mechanics?
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.
Hey, any help here I can't move when I hit Leftshift is my code right? -- 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)
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
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!
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.
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()
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!
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 )
try this humanoid.StateChanged:Connect(function(oldState, newState) if newState == Enum.HumanoidStateType.Jumping then if sprintAnim then sprintAnim:Stop() end end end) humanoid.StateChanged:Connect(function(oldState, newState) if newState == Enum.HumanoidStateType.Landed and isSprinting then if sprintAnim then sprintAnim:Play() end end end)
i cannot get the UI script to work after many attempts, no errors but, when accurately completing the UI as well as the script it just, doesn't work. any suggestions?
@@akwasiasanteampong5103 just chat gpt it, you'll actually get a thorough breakdown of the process, you'll usually have to debug somewhat but it beats having to watch these youtubers who pose as beginner friendly but will then leave stuff out and offer 0 explanation. took me like 20 mins to do this exact thing in chat gpt and i actually learned the functions and the script making it easier for next time.
Im pretty sure you would have to detect when the stamina is equal to or above 100, then make set the gui as invisible, for fading u'll have to use some other variables, i could tell u if u want
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.
This is great!
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!
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..
@@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
@@StillALivingThingdownload RealismMod plugin, it has a ton of options including disable shiftlock
You should definitely keep doing these kinds of tutorials. You explaining what everything is doing actually makes me learn something!
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
THANK YOU SO MUCH BRO YOU SAVED MY GAME
Tysm
W man
BRO TYSM
this only lets me move if i am sprinting
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)
10:29 you can fix that by changing the green bars anchor point, rotating ui in roblox causes issues sometimes and it’s unreliable
for anyone who wants the jump animation to play while sprinting try this
humanoid.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
if sprintAnim then
sprintAnim:Stop()
end
end
end)
humanoid.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Landed and isSprinting then
if sprintAnim then
sprintAnim:Play()
end
end
end)
Yes, man, that was exactly what I was looking for, really needed that cooldown before recharging
Thanks this video is super underrated now i can finally make a horror game
Don’t rush. Take your time and actually let people write the code, and try your best to explain it in a slow manner. No harm I just want to help you!
Thanks bro, your video helped me a lot here :)
For some reason the attributes wont add to the humanoid :/
same problem
it must be a typo somewhere, I had the same issue. After fixing a typo it worked
Stop game then play again
one issue, is that with runservice, the speed changes depending on the player fps, since more frames are rendered, I think a simple way to fix it is the have a "while true do wait(1/60) end" loop, might not be the prettiest but it gives a more consistent stamina.
Hey man, I'm new to coding. I've been trying to find out where to change the runservice but every time I edit it. For some reason the stamina doesn't work. Can you tell me where to change it. Thank you
@@trollersupreme4316 there's the function that the run service activates, all the code inside of that, put it inside the while true do wait(1/60) *put the code here* end
@@catdealer1144 Thank you for the help!
@@trollersupreme4316 be aware it doesn't actually run at 1/60 intervals because of how the code runs, but it's still more consistent than runservice
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
goodlooks wouldn't have figured it out
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?
hey i dont know if he didnt show this but my stamina doesnt regen it goes down then doesnt regen then i cant run no more heres my script -- Script --
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local maxStamina = humanoid:GetAttribute("MaxStamina")
local screen = script.Parent
local staminaBar = screen:WaitForChild("StaminaBar")
local remaining = staminaBar:WaitForChild("Remaining")
humanoid:GetAttributeChangedSignal("Stamina"):Connect(function()
local stamina = humanoid:GetAttribute("Stamina")
remaining.Size = UDim2.new(1, 0, 1 - (1- (stamina / maxStamina)))
end)
this is kind of late but for some reason it doesn’t apply the attributes. i have everything copied word for word yet it still doesn’t let me sprint use stamina etc
the legend is back
Haha thanks man, I hope you enjoy!
just fyi at 12:32 the 1 - (1 - Stamina/MaxStamina) is redundant, all you need is Stamina/MaxStamina (because we want the percentage out of 1, which that already is! :) thanks so much for the tutorial
This worked for me kind of, however it makes it so the stamina bar disappears instantly and the background is just left.
Any help?
I finished everything and the sprint works and stamina but when I start sprinting stand still while still holding shift and run again it doesn't play the animation
Copy and paste this into the sprint Client in starter character scripts:
"-- Services --
local CAS = game:GetService("ContextActionService")
local RNS = game:GetService("RunService")
-- Settings --
local StaminaUsage = 0.5 -- How much stamina to use while running
local RechargeTime = 1 -- How long until stamina starts recharging
-- Script --
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
-- Animation --
local Sprint = script.Sprint
local SprintAnim = humanoid.Animator:LoadAnimation(Sprint)
local LastSprint = math.huge
local IsSprinting = false
local function sprint(actionName, inputState, inputType)
if inputState == Enum.UserInputState.Begin then
IsSprinting = true
elseif inputState == Enum.UserInputState.End then
IsSprinting = false
end
if humanoid.WalkSpeed 0 and humanoid.MoveDirection.Magnitude > 0 and humanoid.WalkSpeed > 0 then
humanoid:SetAttribute("Stamina", stamina - StaminaUsage)
LastSprint = tick()
else
if tick() - LastSprint >= RechargeTime and stamina < humanoid:GetAttribute("MaxStamina") then
humanoid:SetAttribute("Stamina", stamina + StaminaUsage)
end
end
print(humanoid:GetAttribute("Stamina"))
if humanoid.MoveDirection.Magnitude
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!!
7:19 I got to this point where everything stopped working. I've gone through all of my code multiple times and I haven't found where the problem is coming from, but I'm completely unable to sprint.
My current script:
-- Services --
local CAS = game:GetService("ContextActionService")
local RNS = game:GetServivce("deltaTime")
-- Settings --
local staminaUsage = 0.5
local rechargeTime = 1
-- Script --
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local lastSprint = math.huge
local isSprinting = false
local function sprint(actionName, inputState, inputType)
if inputState == Enum.UserInputState.Begin then
isSprinting = true
elseif inputState == Enum.UserInputState.End then
isSprinting = false
end
if isSprinting then
humanoid.WalkSpeed = humanoid:GetAttribute("SprintSpeed")
else
humanoid.WalkSpeed = humanoid:GetAttribute("BaseWalkSpeed")
end
end
CAS:BindAction("Sprint", sprint, true, Enum.KeyCode.LeftShift)
RNS.RenderStepped:Connect(function(delta)
local stamina = humanoid:GetAttribute("Stamina")
if isSprinting then
humanoid:SetAttribute("Stamina", stamina - staminaUsage)
lastSprint = tick()
else
if tick() - lastSprint >= rechargeTime and stamina < humanoid:GetAttribute("MaxStamina") then
humanoid:SetAttribute("Stamina", stamina + staminaUsage)
end
end
print(stamina)
end)
This has also happened to me and nothing is wrong with my code
why did you put deltatime, which is not even a service, in the place of runservice?
This man is the most underrated person in the whole world
what happens to the stamina draining when you have different fps? do you drain more or less stamina depending on your fps
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.
That really feels like an ai generated response lol@@ManlyCreator
use deltaTime instead of fps
idk why but there are no attrubutes on me
is there a way to when you sprint the FOV changes?
for i = 1,5 do
game.Workspace.CurrentCamera.FieldOfView = (110+(i*2))
task.wait()
humanoid.WalkSpeed = humanoid:GetAttribute("SprintSpeed")
end
wait()
else
sprintAnim:Stop()
humanoid.WalkSpeed = humanoid:GetAttribute("BaseWalkSpeed")
for i = 1,5 do
game.Workspace.CurrentCamera.FieldOfView = (110-(i*1.5))
wait(0.00001)
put this in there the wait at the end with 0.00001 is not vital but it putted there for funsies and the task.wait() is so that the player cant spam shift and get inf stamina and the fov is dictated by the place where 110 is at make sure they are both even because if so it won't decrease or increase after you unhold shift
18th like from me. Keep making good content sir.
So ive run into the problem that after the stamina id implemented the sprint speed is immediately cut, the stamina still works but sprint speed dies for spme reason
This is actually good replication techniques and a good tutorial compared to alot in the community nice work!
bro you just gained another subscriber!. Keep the good work up!
can you make the same thing but you also loose stamina when you jump?
How to make the stamina bar horizontal without it bugging out
bro this helped me so much beascuase my code was right. but I didn't known you had to set the scale first.
Can you add a dashing system with this aswell?
when i freeze while i run the runninganim is still going, how do i fix that?
Best tutorial ever! Thank you so much.
I've copied everything exactly, but it won't work. why?
Any errors?
@@AnAvrageRobloxDev yes
what if I want stamina to decrease when I jump
can anyone suggest me
Well, yeah, but we have a problem about frames now, so now - higher frames - higher stamina usage and higher recover speed, any ways to fix that?
When I press Shift it just makes me COMPLETLY stop and I cant walk anymore. I can only jump
did you solve this problem?
@@QQulekks yes i did end up solving the problem bu adding another script
By*
Good then i had the same problem but i needed to check if letters are big or no and instead of putting "." i have put ","
@@Firestarbright what is the script you added to fix it? I'm having this same issue.
if it subtracts stamina by 0.5 every frame, wouldnt that mean that someone on 30 fps would be able to sprint for longer than someone on 120? I may be stupid but i just want to make sure... kinda new to all of this stuff.
Yes, that's why you should use a while task.wait(0.1) do loop than RenderService.
trying to learn lua, great video explains everything and i can just copy what i dont get
totally subbing
the animation loads when u hold shift and standing still
could you do a video on working on stuff 2d related like a 2 camera that works smoothly
That's a good idea. Just like a 2D platformer, right?
@@ManlyCreator yea since thats the type of game im maing
@@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 👍
I have a question for the setting up script part i followed it thoroughly and for some reason the speed didn't change is there something i can do?
is there a way to make the stamina toggle?
I’ve been trying to find a video where they show how to add walking and running animations separately, this video helped me
the stamina bar isnt going down when i sprint how do i fix this
can anyone tell me where to get a character model and which one?
how do i make other actions take stamina as well? dashing or rolling for example
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?
for some reason it wont work for me when i test at 4:13
Same
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.
@@jiggity2538Thanks❤
for the character config, is it possible to add additional attributes for more options like, mana points, vitality points, for additional game mechanics?
Absolutely! Attributes are a very flexible way of controlling any kind of system you want to make.
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.
maybe u could add a timer before the stamina regen event starts
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
Hey, any help here I can't move when I hit Leftshift is my code right? -- 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)
In this case you need to see if you did the other steps right
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
nice video helped a lot
Maybe it's just me, but the GUI isn't working for me. I've followed the steps about three times now yet the stamina remains fully coloured in.
me too
How did you get animations of the marketplace? What?!
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!
Nevermind, I was checking the wrong file, it works for now!
sup dude its zeke w vidoe
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
Yooo, thanks dude. A menu system is a good idea, I'll add that to my to-do list.
How would i code the ui if I made it horizintal
humanoid:GetAttributeChangedSignal("stamina"):Connect(function()
local stamina = humanoid:GetAttribute("stamina")
remaining.Size = UDim2.new( (stamina / maxStamina), 0, 1, 0 )
end)
thanks!@@testdoang6161
thx dawg ❤ @@testdoang6161
@@testdoang6161 Thx so much
why didnt it add the attributes? (i checked and everything was the same)
did you add the comas after the numbers in the module script?
1:57
@@itsbonksy i did but it still wouldnt work, any other solution?
@@singusthetexan an issue i had is i made a typo in the name of the script, maybe check if you spelt it correctly
why is my map uncolided i was falling forever
screen gooey is wild
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
oh its enum.userinputstate.begin not userinputtype
@@abreaddeveloper thanks so much I did this mestake too
can someone send me their script i cant get mine to work
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.
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()
ily
no model?
Can you make a version where the stamina bar only appears when your sprinting?
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!
(i know im necroposting but) you can change the visibility to be true on the background frame whenever you're holding leftshift
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?
You need to increase the recharge time to make it slower
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
Would you mind showing me your script?
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 )
if humanoid.MoveDirection.Magnitude
When im sprinting with the animation when I jump the jump animation doesnt play
try this
humanoid.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
if sprintAnim then
sprintAnim:Stop()
end
end
end)
humanoid.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Landed and isSprinting then
if sprintAnim then
sprintAnim:Play()
end
end
end)
@ Dang I forgot I made this comment. It’s fine I figured it out. Appreciate you trying to help
Pra mim a stamina não desce
How do I make the make the user stop sprinting when he has stopped moving but still holding shift?
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.
if humanoid.MoveDirection.Magnitude
@@ziggykidder8861 Thank god ur a life saver
i cannot get the UI script to work after many attempts, no errors but, when accurately completing the UI as well as the script it just, doesn't work. any suggestions?
the same thing is happpening to me
@@akwasiasanteampong5103 just chat gpt it, you'll actually get a thorough breakdown of the process, you'll usually have to debug somewhat but it beats having to watch these youtubers who pose as beginner friendly but will then leave stuff out and offer 0 explanation. took me like 20 mins to do this exact thing in chat gpt and i actually learned the functions and the script making it easier for next time.
I cant move at all i can jump but thats it
why does it say walkspeed is not a valid member of humanoid? please help
it may be because u typed it wrong, in script its not walkspeed its WalkSpeed(with capitals) and its not humanoid its Humanoid
someone please make a copy and paste script im too lazy to do it myself
- just a lazy guy
it didn't take too long to write and it works very well, you should just write it yourself. It's worth it
can’t find my own character
can you make a more simpler video for my small brain to comprehend
DOES NOT WORK | DECMBER 25TH 2024
i cant see it ( am i blind??)
my stamina isnt draining
nvm, I put :GetAttribute not :SetAttribute
YOUR studio 🤔🤔🤔
Didnt work
W
i dont know why but when i press shift when i idle the animation play, how can i fix this?
bro if i hold shift when i say animation is playing how fix it?
how would i get the ui to fade off screen if im not sprinting
i was trying to do that but i couldn't come up with a way to
Im pretty sure you would have to detect when the stamina is equal to or above 100, then make set the gui as invisible, for fading u'll have to use some other variables, i could tell u if u want