Help with gui spawn system

Hello. I am making a game and I want players to join after clicking a button
in a gui I have the guis done but this is stumping me it just says
(attempt to call a nil value)

object tree is
map(folder) .1
map chosen .2
spawns—siblings .3
primary part—siblings .3


local repStore = game:GetService(“ReplicatedStorage”)
local Event = repStore:WaitForChild(“GUIs”).GUIsButtons.JoinGame

Event.OnServerEvent:Connect(function(plr,typeOfEvent, var, var2)
print(“ok”)
if typeOfEvent == “Join Game” then
local map = game.Workspace:WaitForChild(“Maps”):GetChildren()
local spawner = map:GetChildren().Spawns–:GetChildren()

	local Character = plr.Character	
	local HumanoidRP = Character:WaitForChild("HumanoidRootPart")
	
	if #map > 0 then
	local chosenSpawn = spawner(math.random(1,#spawner))

		
		
		
		print("ok")
	end
end

end)`

What are you doing here exactly…? Wouldn’t this result back as a error? GetChildren returns back a table, you can’t just index it with another Parent inside the map variable

local repStore = game:GetService("ReplicatedStorage")
local Event = repStore:WaitForChild("GUIs").GUIsButtons.JoinGame

Event.OnServerEvent:Connect(function(plr,typeOfEvent, var, var2)
	print("ok")
	if typeOfEvent == "Join Game" then
		local map = game.Workspace:WaitForChild("Maps"):GetChildren()
		local spawner = map:GetChildren()
		--Spawns:GetChildren()

		local Character = plr.Character	
		local HumanoidRP = Character:WaitForChild("HumanoidRootPart")

		if #map > 0 then
			local chosenSpawn = spawner(math.random(1,#spawner))
			print("ok")
		end
	end
end)
1 Like

hey thanks for the reply but i cant seem to get it working im stumped i know its super easy baby level scripting but ive tried different things and they dont seem to work

Can you add a couple more print statements to check what does & doesn’t work?

Is “ok” not printing? if so that means there are no children.

yeah i dont know how to get the children im dumb it works for the other thing for some reason though