I’m just wondering if it’d be more effective to try and combine these three scripts together, or if there were simple improvements I could just make for them individually. Below is the rbxl file, along with screenshots of the scripts if you’d rather just take a look at them. hunger.rbxl (39.2 KB)
Use as few while true’s as possible! Learn about events(Handling Events)
Your hunger is parented to the workspace, it shouldn’t be like that, you should have unique hunger value for each player
Don’t use LocalScript’s for that, you should handle the hunger system on the server side using server scripts, and handle GUIs in the LocalScripts
Also, you seem to be using LocalScripts for this, that’s a huge security flaw for your game. Never trust the client in handling player damage and other vital statistics (for instance in your game, Hunger.). On top of that, your value is parented to the Workspace, you can’t change its value with LocalScripts without using RemoteEvents.
upon on a player joining, a hunger value is added a child of the player.
when the player’s hunger reaches 0, a remoteevent is fired which lowers their health until death, or until they eat.
I understand it’s a potiential security flaw. I’m just getting everything into place the simplest ways I know how. Once my knowledge increases, and the game gets closer to being finished, I plan on looking over the code again.