I'm trying to make a mana charge script that goes back down to 0 slowly after reaching 100.
It's not complete but I decided to test. Didn't work and told me the game script had a timeout Here's the script:
local RS = game:GetService("ReplicatedStorage")
local RE = RS.ManaToggle
RE.onServerEvent:Connect(function()
local ManaValue = Instance.new("IntValue", game.Players.LocalPlayer)
ManaValue.Value = 0
if ManaValue.Value == 100 then return
else
while true do
ManaValue.Value = ManaValue.Value + 1
end
while true do
wait(5)
print(ManaValue.Value)
end
end
end)
Please Help.

5 comments
I'll try it.
It stopped timing out but it doesn't seem to print or work...
This is because you’re loop is yielding the thread below; the thread will interrupt the Script until it’s finished, meaning your while loop will never run. To solve this, you have to split a new thread using spawn() or coroutine.
I'll try coroutine but I'm not sure how to use it.
Oh, I realized you added code, thanks.