Alright I'm implementing a food system into my game and it works fine, but when I die it just stops updating the GUI I have set up. Please help.
Code:
wait(1) local player = game.Players.LocalPlayer local hungerLevels = {full = true, kindof = false, hungry = false, starving = false, dying = false, dead = false} local function check() if hungerLevels.dead then player.PlayerGui.MainUI.ScreenGui.Frame.HungerInteger.Text = "Dead" local calculateDamage = 100 - player.Character.Humanoid.Health player.Character.Humanoid:TakeDamage(calculateDamage) else if hungerLevels.dying then player.PlayerGui.MainUI.ScreenGui.Frame.HungerInteger.Text = "Dying" local message = Instance.new("Message", game.Workspace) message.Text = "YOU ARE DYING OF STARVATION! GO EAT!!!" wait(3) message:Destroy() else if hungerLevels.starving then player.PlayerGui.MainUI.ScreenGui.Frame.HungerInteger.Text = "Starving" else if hungerLevels.hungry then player.PlayerGui.MainUI.ScreenGui.Frame.HungerInteger.Text = "Hungry" else if hungerLevels.kindof then player.PlayerGui.MainUI.ScreenGui.Frame.HungerInteger.Text = "Okay" else if hungerLevels.full then player.PlayerGui.MainUI.ScreenGui.Frame.HungerInteger.Text = "Full" end end end end end end end local function starvationSystem() check() wait(60) hungerLevels.full = false hungerLevels.kindof = true check() wait(60) hungerLevels.kindof = false hungerLevels.hungry = true check() wait(60 * 2) hungerLevels.hungry = false hungerLevels.starving = true check() wait(60 * 2) hungerLevels.starving = false hungerLevels.dying = true check() wait(60 * 3) hungerLevels.dying = false hungerLevels.dead = true check() end while player.Character.Humanoid.Health > 0 do starvationSystem() end
while player.Character.Humanoid.Health > 0 do starvationSystem() end
Of course it stops updating. That line of code is saying; "while the localplayer's health is above 0, run the starvationsystem."