Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I make both functions run?

I have hunger and thirst script, and I want them runat same time, I do know why they won't, but I don't know how do I make them run at same time.

local hunger = script.Parent.Parent.Hunger --Max Hunger = 100, Min Hunger = 0, as you can soon realize
local thirst = script.Parent.Parent.Thirst --Same Here

function hungerReducer(value)
	repeat wait(12)
		value.Value = value.Value -1
	until value.Value == 0
end
function thirstReducer(value)
	repeat wait(6)
		value.Value = value.Value -1
	until value.Value == 0
end

hungerReducer(hunger)
thirstReducer(thirst)

It's kinda easy question to answer.

Thanks,

SwaggyDuckie

1 answer

✓ Accepted answer

Learn coroutines.

coroutine.resume(coroutine.create(function()
while wait(1) do
print("hey")
end
end))

wait(.5)

coroutine.resume(coroutine.create(function()
while wait(1) do
print("hi")
end
end))

This discussion is preserved as it was. New answers, comments, and votes are closed.