ProfileService Hunger system not functioning properly

I am creating a serverscript that lowers everyones hunger and thirst values, it uses ProfileService to handle stats and also save them, so when they leave they keep the amount of hunger/thirst they had.

It works fine in studio when testing it by myself, but when I run a test server the values it prints are all over the place, sometimes it says a players hunger is 2700 othertimes its like 190, and for reference the profileservice template has hunger and thirst set to 100 by default

I will leave my method of lowering stats and the script that runs the functions.

This is the manager that handles lowering stats

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage.Remotes
local module = {}

module.Profiles = {}

function module.AdjustHunger(player: Player, amount: number)
	local profile = module.Profiles[player]
	if not profile then return end
	profile.Data.PlayerStats.Hunger = profile.Data.PlayerStats.Hunger - amount

function module.AdjustThirst(player: Player, amount: number)
	local profile = module.Profiles[player]
	if not profile then return end
	profile.Data.PlayerStats.Thirst = profile.Data.PlayerStats.Thirst - amount

return module

This is the Serverscript that depletes hunger and thirst, hunger every 3 seconds and thirst every 6 seconds

while HungerSystem and ThirstSystem do
	for _, player in Players:GetPlayers() do
		local profile = PlayerData.Profiles[player]
		if not profile then continue end
		local CurrentTime = tick()
		if CurrentTime - HungerSystemTime >= HungerSettings.HungerDecreaseTime then
			PlayerData.AdjustHunger(player, HungerSettings.HungerDecreaseAmount)
			HandleStarvation(player, profile)
			HungerSystemTime = CurrentTime
			print(player.Name..profile.Data.PlayerStats.Hunger.." Hunger")
		if CurrentTime - ThirstSystemTime >= ThirstSettings.ThirstDecreaseTime then
			PlayerData.AdjustThirst(player, ThirstSettings.ThirstDecreaseAmount)
			HandleDehydration(player, profile)
			ThirstSystemTime = CurrentTime
			print(player.Name..profile.Data.PlayerStats.Thirst.." Thirst")

If you need extra info or need me to provide more of my code I will, I’ve been debugging this for a while and tried other methods and haven’t figured out what’s going on so thank you to anybody who looks into this :slight_smile:

I am also very new to ProfileService, I learnt it a few days ago. I was originally gonna make my own datastores but I heard profileservice is a better option.