Ok so I have this script
local CAS = game:GetService("ContextActionService")
local RE = game:GetService("ReplicatedStorage"):WaitForChild("RE")
local fill = script.Parent:WaitForChild("Top"):WaitForChild("fill")
local stam = 50
local speed = 16
local sprinting = false
local function sprint(str, state, object)
if stam < 1 then return end
speed = state == Enum.UserInputState.Begin and 24 or 16
sprinting = state == Enum.UserInputState.Begin
while sprinting and stam > 0 and wait(.1) do
stam = stam - 1
fill:TweenSize(UDim2.new(stam/50,0, 1, 0), "Out", "Quint", .1, true)
RE:FireServer("sprint", {speed})
end
sprinting = false
speed = 16
RE:FireServer("sprint", {speed})
wait(1)
while not sprinting and stam < 50 and wait(.1) do
fill:TweenSize(UDim2.new(stam/50,0, 1, 0), "Out", "Quint", .1, true)
stam = stam + 1
end
end
CAS:BindAction("sprint", sprint, true, Enum.KeyCode.LeftShift)
Now is there a way to make it take away thirst as well and if so how would I do that?

9 comments
yes, drink water bro, ur dehydrated
lol ok well I'm still really new to this I started like 3 days ago how would I go about doing it?
So you're telling me in 3 days you're already abusing the while wait() do idiom
is that a bad thing? its just what i saw someone else do in a lua tutorial video so i decided to implement it into this script
in 3 days you can already make a whole script by yourself? wow! great job!
If you don't know how the while wait() do idiom works, simply don't use it. Using a while true do loop is much clearer.
I didnt make it all by myself i was in a call with a friend who was helping me with some of it
If HE doesn't know how it works, HE also shouldn't be using it.
he does hes just at work so i cant ask him for help