commands.endround = function(sender) -- End round command
print("End round command fired by "..sender.Name)
local map = game.Workspace.ChosenMap:GetChildren()
map.Gems:GetChildren():Destroy()
print("Round ended")
end
This is a command I made to end the current round. The command its self works except for one part-line 7-"Attempt to index nil with 'GetChildren'"
When the main script spawns in the map, it gets put into the chosen map folder. Every map has a gems folder with all the gems that need to be found, they get destroyed once found. When all the gems in the gems folder are found, the round automatically ends. So this script is supposed to destroy the gems that way the other script (the main script) can end the round. But I get an error, why is this?
Also can someone please tell me what attempt to index nil means?
Thanks!

4 comments
I've had this problem like 20 times and I still don't remember how I got around it...
Can I see where you're running the function?
The function runs when you say "/endround" which works because it prints out "End round command fired by [name]"
Also I was following a tutorial, Alvin_Blox admin commands tutorial.