I'm getting the Player's name and putting in a list that can be randomly called from all servers (old and new)
i know how to make both datastores and tables. what I don't know is which one would be better for this
example: I join my game and it sends my name to the list, meanwhile in another server, someone is walking (the way i have it to randomly pick a name) and they see my name.
I need it to save all player's name that join the game
local DS = game:GetService("DataStoreService"):GetDataStore("Players");
game.Players.PlayerAdded:connect(function(plr)
DS:UpdateAsync("PlayerListTest", function(oldTable)
local newTable = oldTable
if not newTable[plr.UserId] == true then
table.insert(newTable, plr.UserId); -- This inserts the players userid into the table. That way if they changeg their name it will work still.
end;
return newTable
end)
script.Parent.Touched:connect(function()
for key, value in pairs(newTable) do -- newTable has the blue line under it here
local picked = math.random(key, value)
print(value)
end
end)
end)

4 comments
I believe that a datastore would work better for this.
You have to use datastore to do stuff like that. Not sure how fast datastore is, though, so it might not work great.
I mean, if you have your own web server, you could query to and from it with HttpService as well - if you know a little PHP :P Datastore is probably your best bet here.
I learned PHP and made a forum website when I was 10. xD