This is a very strange problem. Whenever I call "SetPlayerData" in my "DataModule", it's supposed to set "playerId"'s data to a value. What it does instead is it updates everyone's XP value to that value. I did a little bit more bug testing (4 hours more) and came to the realization that it wasn't just the XP that was doing this, but also every other key in the table. This is the code that I call to update someone's data:
module.SetPlayerData = function(playerId, stat, updateFunc) -- Sets the specified 'stat' to the value of 'updateFunc' for the specified player with 'playerId' module.Data[tostring(playerId)][stat] = updateFunc(module.Data[tostring(playerId)][stat]) print("setting " .. game.Players:GetPlayerByUserId(playerId).Name .. "'s " .. stat .. " to " ..tostring(module.GetPlayerData(playerId)[stat])) end
The print statement only prints once but everyone's data gets changed... Why is this happening ;-;