Script won´t work

this script won´t work:

local player = game.Players:GetPlayers()

if player >  2 then
	for i, v in pairs(player) do
		if v.Character then
			v.Character.HumanoidRootPart.Position = game.Workspace:FindFirstChild("tp45").Position
		elseif player < 2  then
			print("not enough players ")
			
		
		end
	end
	
end

there is also a error in the output saying;

ServerScriptService.Playerscript:3: attempt to compare number < table

pls any feedbacks would be cool!

Ok, 3 problems.

  • You are comparing a number with a table.
  • You also put the elseif player < 2 then in the wrong place.
  • You want the amount of players to be greater than 2, but less than 2?
local plrs = game.Players:GetPlayers()

if #plrs > 1 then
    for i, v in plrs do
        if v.Character and v.Character:FindFirstChild('HumanoidRootPart') then
			v.Character.HumanoidRootPart.Position = workspace.tp45.Position
        end
    end
else -- there is only 1 player or 0 players
    print('less than 2 players')
end
4 Likes

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