Hello everyone, I am making a roblox game that includes an eating, and starvation feature. My eating script is causing an error, also, the console is not showing any errors so im 100% sure that my code is just buggy. I will include the starvation script and the eating script Whenever I eat some food, the next time it goes to remove a bit of hunger, it removes WAY too much
Eating script:
food = "Food" hunger = "Hunger" script.Parent.MouseButton1Click:Connect(function() for i, v in pairs(game.Players:GetPlayers())do if v:FindFirstChild("leaderstats")then if v.leaderstats[food].Value == 0 then print("error") else if v.leaderstats[hunger].Value == 20 then print("error") else if v.leaderstats[hunger].Value + 5 > 20 then v.leaderstats[hunger].Value = 20 v.leaderstats[food].Value = v.leaderstats[food].Value - 1 else v.leaderstats[hunger].Value = v.leaderstats[hunger].Value + 5 v.leaderstats[food].Value = v.leaderstats[food].Value - 1 end end end end end end)
starvation script:
hunger = "Hunger" while true do wait(0.000000001) for i,v in pairs(game.Players:GetPlayers())do if v:FindFirstChild("leaderstats")then if v.leaderstats[hunger].Value == 0 then v.Character.Humanoid.Health = 80 wait(2) v.leaderstats[hunger].Value = 0 v.Character.Humanoid.Health = 60 wait(2) v.leaderstats[hunger].Value = 0 v.Character.Humanoid.Health = 40 wait(2) v.leaderstats[hunger].Value = 0 v.Character.Humanoid.Health = 20 wait(2) v.leaderstats[hunger].Value = 20 v.Character.Humanoid.Health = 0 end end end end