Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can I make this take away thirst too somehow?

Asked by 4 years ago

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?

0
yes, drink water bro, ur dehydrated greatneil80 2647 — 4y
0
lol ok well I'm still really new to this I started like 3 days ago how would I go about doing it? slysnake2000 0 — 4y
0
So you're telling me in 3 days you're already abusing the while wait() do idiom User#24403 69 — 4y
0
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 slysnake2000 0 — 4y
View all comments (5 more)
0
in 3 days you can already make a whole script by yourself? wow! great job! User#28022 0 — 4y
0
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. DeceptiveCaster 3761 — 4y
0
I didnt make it all by myself i was in a call with a friend who was helping me with some of it slysnake2000 0 — 4y
0
If HE doesn't know how it works, HE also shouldn't be using it. DeceptiveCaster 3761 — 4y
0
he does hes just at work so i cant ask him for help slysnake2000 0 — 4y

Answer this question