Attempt to call a nil value

After the timer ends, i want every player from the remaining in the game, to teleport to the spawn point.(It’s a minigames place)

This is the script(Where the problem is):

	if roundLenght == 0 then
		status.Value = "Time's up!"
		wait()
		workspace.Ingame:GetChildren("Model"):MoveTo(workspace.SpawnLocation.Position) -- problem/error
	end

Full code:

local status = game.ReplicatedStorage.Status
local maps = game.ReplicatedStorage.Maps:GetChildren()

while true do
	for i = 1,10 do
		status.Value = "Intermission: "..10-i
		wait(1)
	end
	
	local rand = math.random(1, #maps)
	
	local map = maps[rand]:Clone()
	map.Parent = workspace
	
	status.Value ="We'll be playing "..map.Name.."!"
	wait(4)
	
	local players = game.Players:GetChildren()
	for i = 1,#players do
		if players[i].Character ~= nil then
			local spawnLocation = workspace.Teleports:FindFirstChild(map.Name)
			players[i].Character:MoveTo(workspace.Teleports:FindFirstChild(map.Name).Position)
		    players[i].Character.Parent = workspace.Ingame
		end
	end
	
	local roundLenght = 0
	local CanWin = true
	local roundType = ""
	
	if map:FindFirstChild("Obby") then
		roundType = "Obby"
		map.EndPart.Touched:Connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") then
				CanWin = false
				status.Value = hit.Parent.Name.." has won!"
			end
		end)
	elseif map:FindFirstChild("Sword") then
		roundType = "Sword"
		
		local children = workspace.Ingame:GetChildren()
		for i = 1,#children do
			map:FindFirstChild("ClassicSword"):Clone().Parent = children[i]
		end
		
		map:FindFirstChild("ClassicSword"):Destroy()
	end
	
	
	if map.Name == "the Lava Race" then
		roundLenght = 10
	end
	
	if map.Name == "a Sword Fight" then
		roundLenght = 10
	end
	
	repeat
		roundLenght = roundLenght -1
		status.Value = "Time Left: "..roundLenght
		wait(1)
	until roundLenght == 0 or CanWin == false or #workspace.Ingame:GetChildren() == 0 or (#workspace.Ingame:GetChildren() == 1 and roundType == "Sword")
	

	
	
	if #workspace.Ingame:GetChildren() == 1 and roundType == "Sword" then
		status.Value = workspace.Ingame:FindFirstChildWhichIsA("Model").Name.." has won!"
		wait()
		workspace.Ingame:GetChildren("Model"):MoveTo(workspace.SpawnLocation.Position)
	end	
	
	if roundLenght == 0 then
		status.Value = "Time's up!"
		wait()
		workspace.Ingame:GetChildren("Model"):MoveTo(workspace.SpawnLocation.Position)
	end
	
	wait(3)
	
map:Destroy()
end

(InGame is a folder witht the players in the minigame)

If u have any questions, comment and i will respond as fast i can!

Thank you!

if roundLenght == 0 then
		status.Value = "Time's up!"
		wait()
		workspace.Ingame:GetChildren("Model").CFrame = workspace.SpawnLocation.CFrame
	end

The problem is that you only got the children then unprotectedly moved the child that are considered Model in your perspective, here is what you need to do.

for i, v in pairs(workspace.Ingame:GetChildren()) do
if v:IsA('Model') then
v:MoveTo(blahblahyoucompleteIt)
end
end
1 Like