function dataManager:GetClass(player)
local user = playersData[player.UserId]
if not user then return end
print('GetClass', player, user.EquippedClass) -- Prints other players classes)
return user.EquippedClass
end
Ignore all the prints. Problem is that if a player changes their class and reset, they get given that class, but if another player resets, they get given the same class as the other players class.
So basically,
Player1 and Player2 are both Knights. Player1 changes their class to Archer, and reset. They respawn as an archer. Player2 dies/resets and they respawn as an archer, even tho they should still be a Knight.
I’d recommend only posting the code relevant to the problem because I just spent 5 minutes reading the first function and wondering how it’s related to your problem.
function dataManager:GetClass(player)
local user = playersData[player.UserId]
if not user then return end
print('GetClass', player, user.EquippedClass)
return user.EquippedClass
end
Basically, if Player1 changes their class to Archer and Player2 dies with Knight still equipped, it prints
Think I found the problem, but not sure why it is so.
So testing in studio on 2 player server, printing
user
returns the same same table for both players. Not sure if this is suppose to happen? I’d think that each player would have their own individual table??
You’re not giving enough information. Based on the function you provided, yes, each user should have their own information. But this is assuming at least two things:
You’re storing data for each player separately, and not accidentally tangling them together.
You’re storing each piece of data under the appropriate UserId.
Problems like these are usually extremely simple to fix but difficult to solve because of assumptions being made. Try breakpointing in a few key areas and see what data you’re actually dealing with.