local allPlayers = {} for a,v in pairs(game.Players:Getchildren(2)) do table.insert(allPlayers,v) end local plrAmount = game.Players.Numplayers local val1 = math.random(plrAmount) local val2 repeat val2 = val2 - math.random(plrAmount) wait(20) until val2 ~=val1 allPlayers[val1].Character.Torso.CFrame = CFrame.new(0,0,0) allplayers[val2].Character.Torso.CFrame = CFrame.new(665.995,7.1,-115.005) math.randomseed(os.time())
it says Getchildren is not a valid member of Players (in output)
local allPlayers = {} for a,v in pairs(game.Players:GetChildren(2)) do -- Lua is case sensitive. table.insert(allPlayers,v) end local plrAmount = game.Players.Numplayers local val1 = math.random(plrAmount) local val2 repeat val2 = val2 - math.random(plrAmount) wait(20) until val2 ~=val1 allPlayers[val1].Character.Torso.CFrame = CFrame.new(0,0,0) allplayers[val2].Character.Torso.CFrame = CFrame.new(665.995,7.1,-115.005) math.randomseed(os.time())
local allPlayers = {} for a,v in pairs(game.Players:GetChildren()) do --two typos here table.insert(allPlayers,v) end local plrAmount = game.Players.Numplayers local val1 = math.random(plrAmount) local val2 repeat val2 = val2 - math.random(plrAmount) wait(20) until val2 ~=val1 allPlayers[val1].Character.Torso.CFrame = CFrame.new(0,0,0) allplayers[val2].Character.Torso.CFrame = CFrame.new(665.995,7.1,-115.005) math.randomseed(os.time())
This is your script, there's easier ways of doing this. Instead of having a generic for loop search through a table of all the players and insert them all into another table. You can get rid of the whole generic loop.
local allPlayers = game.Players:GetChildren() local plrAmount = game.Players.Numplayers local val1 = math.random(plrAmount) local val2 repeat val2 = val2 - math.random(plrAmount) wait(20) until val2 ~=val1 allPlayers[val1].Character.Torso.CFrame = CFrame.new(0,0,0) allplayers[val2].Character.Torso.CFrame = CFrame.new(665.995,7.1,-115.005) math.randomseed(os.time())