You are getting this error because you are trying to call a table like how you would call a function; Your local variable 'spawns' is a table containing all of the children inside 'Spawns'; Lua thinks that you are trying to call spawns with the argument 'allspawns'; If you want to spawn a player at a random spawn inside of Spawns, than you should use math.random to get an index of each child inside the table; sounds confusing right? Well here how you can actually do this in your code:
math.randomseed(os.time())
local function WarmUp()
math.random();
math.random();
math.random();
end
local spawns = chosenmap:WaitForChild("Spawns"):GetChildren();
WarmUp();
local random_spawn_index = math.random(1, #spawns);
local randomspawn = spawns[random_spawn_index];
Since you are a beginner in Lua I am not going to go into too much detail of what this is doing, but I will tell you that #spawns actually gets the length of the spawns table (i.e. how many elements/objects are inside of it), so if there are 10 spawns inside of Spawns, and we want to pick a random one, we just generate a random number between 1, and #spawns (in this case #spawns would be equal to 10)
I hope this helped you.
1 comment
What do you expect spawns(allspawns) to do? Spawns is a table, and this piece of code makes no sense.