ServerScriptService.System:11: attempt to index nil with 'HumanoidRootPart'

Hello!
I’m trying to make a countdown that’s teleport You but evertime the countdown ends I get this error

ServerScriptService.System:11: attempt to index nil with ‘HumanoidRootPart’

Here’s The Script

local counter = game.ReplicatedStorage.time
local plrs = game.Players:GetChildren()

while true do
	repeat
	counter.Value = counter.Value - 1
	wait(1)
	until counter.Value == 0
	counter.Value = 60
	wait(2)
	plrs.Character.HumanoidRootPart.Position = workspace.secondmap.teleports.map2spawn2.Position
	
end

here is the error code

	plrs.Character.HumanoidRootPart.Position = workspace.secondmap.teleports.map2spawn2.Position
1 Like

“plrs” is an array of all the players

there is no Character property or HumanoidRootPart property of an array

And the solution is to iterate over the array

for i = 1, #plrs do
    if plrs[i].Character then
        plrs[i].Character.HumanoidRootPart.Position = workspace.secondmap.teleports.map2spawn2.Position
    end
end
2 Likes