And so basically the first player to join should get 100, and the name of that plot should be 100_Player1. Then the next player would get 102_Basic, with the name becomming 102_Player2, and so on. (hope this explains it a lil more )
If the numbers at the beginning are only going to be 3 digits(100-999) then to get the number as a string you can just sub the first 3 characters like so:
local originalName = "100_Basic"
local playerName = "cheeseMan"
print(string.sub(originalName,1,3).."_"..playerName)
outputs → 100_cheeseMan
however if you plan to use any different kind of number I would use string.match() and get digit characters like so
local originalName = "100191_Basic"
local playerName = "cheeseMan"
print(string.match(originalName,"%d+").."_"..playerName)
Outputs → 100191_cheeseMan
If you’re wondering how this works it matches the string for the pattern of '“%d+” the %d meaning digit characters and the + meaning get all digit characters in the first match we can.
How would I go about checking for their plot from other scripts? Normally I’d have this
local playersPlot = plots:WaitForChild(player.Name)
But now since I have numbers in front I can’t. Is there a way to check for the players name in a model? Preferably not from using a for loop or whatever. I’d like to be able to just get it from one line
In that case, I would either save a value in a value object or a table, which tells the player and the player’s plot name or just loop through all the plots and see if the name of the plot of has the player’s name in it using string.match. The best one-line option would just be to save the plot in an object value or string value or in a dictionary, where the key is the player’s name and the value is the plot or plot name. (If it should be accessible to other scripts use a module script)