Script doesnt workk

this script won´t work:

local player = game:GetService("Players")

local tp1 = game.Workspace:FindFirstChild("Tp1")
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		for i, v in pairs(player) do
			if v:FindFirstChild("Character") then
				if v >= 2 then
					print(" enough players")
					v.Character.HumanoidRootPart.Position = tp1.Position
				else
					print(" not enough players")
				end
			end
		end
	end
end)

and it also won´t print anything!
i got this error:

 Workspace.Part.Script:5: invalid argument #1 to 'pairs' (table expected, got Instance)
2 Likes

The Players service isn’t a table, you need to use player:GetPlayers() and check if v.Character then…
Hope this helps!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.