How come playerdata is being duplicated?

I store playerdata in a table on the server, with their userid as the key. For some reason, when i change 1 players data, the others changes too for no reason. So every player gets their data changed

local PlayerData = require(ServerStorage.PlayerData)

-- to get playerdata
PlayersData = PlayerData[player.UserId]

-- making a change
PlayersData.Coins += 50

and so, lets say I update player1 coins, and then print the PlayerData module, it says both Player1 and Player2 have an extra 50 coins, even tho I am only calling a single player, so when I do PlayersData, it does only print the players data.

Further explanation:
When players load, I store their data as such

PlayerData = {
    [1] = {Coins = 0},
    [2] = {Coins = 0}
}

So player id as key, their data. Then, when I wanna change a certain players data, I

local PlayerData = require(ServerStorage.PlayerData) -- This returns the above table

-- to get playerdata
PlayersData = PlayerData[player.UserId]

-- And then add on the player 1's coins
PlayersData.Coins += 50

Now problem is, if I then do

print(PlayerData)

after, both player1 and player2 now have 50 coins, even tho I am ONLY giving coins to 1 player (I put a print above the addition of coins to confirm that only 1 player is getting them

PlayersData = PlayerData[player.UserId]

print(player) -- this ONLY prints Player1

PlayersData.Coins += 50

but still, somehow player2 also magically gets coins

If updating a table leads to another table getting updated there can only be one explanation and major suspicion, that they are the same table.

Be sure to create a new table for each player.

https://developer.roblox.com/en-us/articles/Cloning-tables

To double check print out the table ID in console, enable show memory address for each table

1 Like