Attempt to index nil with 'TempContestants'

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    This script is supposed to give player swords, though the script this happens is cloned from “ServerStorage”, I did this so my game could have both random maps and gamemodes, TempContestants is a folder kept on the map models, and it has “Object Values” of Players currently playing.
  2. What is the issue? Include screenshots / videos if possible!
    Whenever the script for the sword gamemode activates, it for some reason it does not give the player swords, and giving me the error "Attempt to index nil with “TempContestants”error, the game does manage to access the map and the gameinfo folder.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve already tried looking for solutions on the developer hub, and stuff like adding “Wait()” in case the script went off before it was filled in.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Map = game.Workspace.LoadedMap:GetChildren()

for i,v in pairs (Map.GameInfo.TempContestants:GetChildren()) do
	if v.Value then
		local player = v.Value
		if player and player.Character then
			local humanoid = player.Character:FindFirstChild("Humanoid")
			if humanoid then
				local sword = game.ServerStorage.Tools.Swordd:Clone()
				sword.Parent = player.Backpack

It appears that there’s a problem with ‘GameInfo’. Review that

‘Map’ is


Is basically


Which does not make any sense.

1 Like

“Map” is a table because GetChildren returns a table of all the children of the object you called it on.

If there is only one map in “LoadedMap” then you could try

local Map = workspace.LoadedMap:GetChildren()[1]

which would return the 1st object from the table

Yep this actually worked. Thanks for the quick response!

Thank you, I learnt something new.