I am wondering if there will be any chances of conflicts? Or is it safe???
Not sure if it is possible for two players to have the same name. I believe that ROBLOX has some kind of alias name system now??? Does anybody have any experience with this or know?
Well yes, but im sure there is a work around to this.
Posibly a separate table that stores the the PlayerId relative to the player name.
Here is an example
local P_ID_t = {
[Player.Name] = Player.UserId
}
Then when you want to access the player, simply use the table
local tableofplayers = {
[1234567890] = "SuperEpicCoolDude";
}
print(tableofplayers[P_ID_t[Player.Name]]) -- Prints SuperEpicCoolDude
Its a weird way around it but if it helps then it works!
I hope this helps!
Roblox has built-in functions to reference the player with different types of data.
Remember, there’s player.Name, player.DisplayName and player.UserId, all properties of the player instance. DisplayName will not be used for referencing and differentiating players. Name is fine, but players can change names, so it’s better to use the permanent UserId for data storing, teleporting and so forth.
Let’s say you want to reference me, and I can be found among players in the Players service.
You know my name:
local me = Players:FindFirstChild("my_username")
if me then ... end
:FindFirstChild() is for precauting in case I am not there to be found
You know my username:
local me = Players:GetPlayerByUserId(my_id_here)
if me then ... end
Then there are also async versions for players that are not in game.
GetNameFromUserIdAsync(name_here) and GetUserIdFromNameAsync(id_here)
Of course, you often don’t need these functions because my player instance will be passed when I join.
game:GetService("Players").PlayerAdded:Connect(function(player)
-- when I join, that's me
end)