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.
Loops can run faster than ROBLOX can handle, you always need to add a wait()
within any form of repetitive reiteration
spawn(function() while true do wait() --// Code end end) --// Code