So I’m planning on making a script which manages the player’s thirst and hunger drain, my first ideas were to either store them in the character, making the variables a child of that (which may bring up problems if the character dies), or in the player itself, making the variables a child of that (if that’s even possible)
However problems arise in that I want the script to be capable of accessing and writing datastores, which is not possible in a localscript which the starterplayer and startercharacter folders require.
Would it be possible to have a script in the server that manages all this for each player, and if so, how would I handle managing it for each player?
You can use server scripts for StarterCharacterScripts, which may open back up some possibilities for you. You can also use a local script and use remote events / functions to send information over to the server.
You can also handle each player’s stats in a single server script by just using PlayerAdded and/or CharacterAdded events.
I would put the thirst and hunger value inside of the Player object so you don’t have to worry about saving the values each time the player dies. Have a script inside of ServerScriptService that every once in a while drains the hunger of each player. To manage it for each player you can just use a for loop like
for i, v in pairs(game:GetService("Players"):GetPlayers()) do
if (v.Character and v.Character:FindFirstChild("Humanoid")) then
--Remove some thirst and hunger from the player
end
end