local lobby = game.Workspace.LobbyTeleport
local inRound = game.ReplicatedStorage.InRound
local playersInPartRegion = {game.Workspace.BattleZoneAreaPart}
local playerisIn = false
game.ReplicatedStorage.AddPlayerToTable.OnServerEvent:Connect(function(PlayerToAdd)
table.insert(playersInPartRegion,PlayerToAdd.Name)
end)
game.ReplicatedStorage.RemovePlayerFromTable.OnServerEvent:Connect(function(PlayerToRem)
local Count = 0
for _,index in pairs(playersInPartRegion) do
Count = Count + 1
if index == PlayerToRem.Name then
table.remove(playersInPartRegion,Count)
break
end
end
end)
while wait(1) do
if #playersInPartRegion < 3 and #playersInPartRegion > 0 then
for _, player in pairs(game.Players:GetChildren()) do
for i,index in pairs(playersInPartRegion) do
if index == player.Name then
local char = player.Character
char:MoveTo(lobby.Position)
end
end
end
playersInPartRegion = {}
end
end
Try This I Guess?
1 Like
It still doesn’t work.
This is the script:
local lobby = game.Workspace.LobbyTeleport
local inRound = game.ReplicatedStorage.InRound
local playersInPartRegion = {game.Workspace.BattleZoneAreaPart}
local playerisIn = false
game.ReplicatedStorage.AddPlayerToTable.OnServerEvent:Connect(function(PlayerToAdd)
table.insert(playersInPartRegion,PlayerToAdd.Name)
end)
game.ReplicatedStorage.RemovePlayerFromTable.OnServerEvent:Connect(function(PlayerToRem)
local Count = 0
for _,index in pairs(playersInPartRegion) do
Count = Count + 1
if index == PlayerToRem.Name then
table.remove(playersInPartRegion,Count)
break
end
end
end)
while wait(1) do
if #playersInPartRegion < 2 and #playersInPartRegion > 0 then
for _, player in pairs(game.Players:GetChildren()) do
for i,index in pairs(playersInPartRegion) do
if index == player.Name then
local char = player.Character
char:MoveTo(lobby.Position)
end
end
end
playersInPartRegion = {}
end
end
Anything In Output?
Also Try this Script.
local lobby = game.Workspace.LobbyTeleport
local inRound = game.ReplicatedStorage.InRound
local playersInPartRegion = {game.Workspace.BattleZoneAreaPart}
local playerisIn = false
game.ReplicatedStorage.AddPlayerToTable.OnServerEvent:Connect(function(PlayerToAdd)
table.insert(playersInPartRegion,PlayerToAdd.Name)
print(PlayerToAdd.Name)
end)
game.ReplicatedStorage.RemovePlayerFromTable.OnServerEvent:Connect(function(PlayerToRem)
local Count = 0
for _,index in pairs(playersInPartRegion) do
Count = Count + 1
if index == PlayerToRem.Name then
table.remove(playersInPartRegion,Count)
break
end
end
end)
while wait(1) do
if #playersInPartRegion < 2 and #playersInPartRegion > 0 then
for _, player in pairs(game.Players:GetChildren()) do
for i,index in pairs(playersInPartRegion) do
if index == player.Name then
local char = player.Character
char:MoveTo(lobby.Position)
end
end
end
playersInPartRegion = {}
end
end
When you use this Script,
Test it out and See what it prints in output
1 Like
For the last script, I don’t remember well, but I think there wasn’t any errors for this script, and for the new script, it prints out my name. It says Ojnim0702 (x4421).
Also, thank you for helping me this long.
1 Like
local lobby = game.Workspace.LobbyTeleport
local inRound = game.ReplicatedStorage.InRound
local playersInPartRegion = {game.Workspace.BattleZoneAreaPart}
local playerisIn = false
game.ReplicatedStorage.AddPlayerToTable.OnServerEvent:Connect(function(PlayerToAdd)
table.insert(playersInPartRegion,PlayerToAdd.Name)
end)
game.ReplicatedStorage.RemovePlayerFromTable.OnServerEvent:Connect(function(PlayerToRem)
local Count = 0
for _,index in pairs(playersInPartRegion) do
Count = Count + 1
if index == PlayerToRem.Name then
table.remove(playersInPartRegion,Count)
break
end
end
end)
while wait(1) do
if #playersInPartRegion < 2 and #playersInPartRegion > 0 then
for _, player in pairs(game.Players:GetChildren()) do
for i,index in pairs(playersInPartRegion) do
if index == player.Name then
print(player.Name)
local char = player.Character
char:MoveTo(lobby.Position)
end
end
end
playersInPartRegion = {}
end
end
Try this and Check what it prints
1 Like
In the output, it prints nothing.
1 Like
local lobby = game.Workspace.LobbyTeleport
local inRound = game.ReplicatedStorage.InRound
local playersInPartRegion = {game.Workspace.BattleZoneAreaPart}
local playerisIn = false
game.ReplicatedStorage.AddPlayerToTable.OnServerEvent:Connect(function(PlayerToAdd)
table.insert(playersInPartRegion,PlayerToAdd.Name)
end)
game.ReplicatedStorage.RemovePlayerFromTable.OnServerEvent:Connect(function(PlayerToRem)
local Count = 0
for _,index in pairs(playersInPartRegion) do
Count = Count + 1
if index == PlayerToRem.Name then
table.remove(playersInPartRegion,Count)
break
end
end
end)
while wait(1) do
if #playersInPartRegion < 2 and #playersInPartRegion > 0 then
for _, player in pairs(game.Players:GetChildren()) do
for i,index in pairs(playersInPartRegion) do
if player.Name == index then
local char = player.Character
char:MoveTo(lobby.Position)
end
end
end
playersInPartRegion = {}
end
end
Does this teleport you?
1 Like
No, it doesn’t teleport players.
Is the name of the RemoteEvents causing the error that doesn’t teleport players?
1 Like
No, Its not that.
Let me see what the problem is.
1 Like
local lobby = game.Workspace.LobbyTeleport
local inRound = game.ReplicatedStorage.InRound
local playersInPartRegion = {}
local playerisIn = false
game.ReplicatedStorage.AddPlayerToTable.OnServerEvent:Connect(function(PlayerToAdd)
table.insert(playersInPartRegion,PlayerToAdd.Name)
end)
game.ReplicatedStorage.RemovePlayerFromTable.OnServerEvent:Connect(function(PlayerToRem)
local Count = 0
for _,index in pairs(playersInPartRegion) do
Count = Count + 1
if index == PlayerToRem.Name then
table.remove(playersInPartRegion,Count)
break
end
end
end)
while wait(1) do
if #playersInPartRegion < 3 and #playersInPartRegion > 0 then
for _, index in pairs(playersInPartRegion) do
if game.Players:FindFirstChild(index) then
local player = game.Players:FindFirstChild(index)
if player.Character then
player.Character:MoveTo(lobby.Position)
end
end
end
end
end
1 Like
The output prints out “Passed one”.
local lobby = game.Workspace.LobbyTeleport
local inRound = game.ReplicatedStorage.InRound
local playersInPartRegion = {}
local playerisIn = false
game.ReplicatedStorage.AddPlayerToTable.OnServerEvent:Connect(function(PlayerToAdd)
table.insert(playersInPartRegion,PlayerToAdd.Name)
end)
game.ReplicatedStorage.RemovePlayerFromTable.OnServerEvent:Connect(function(PlayerToRem)
local Count = 0
for _,index in pairs(playersInPartRegion) do
Count = Count + 1
if index == PlayerToRem.Name then
table.remove(playersInPartRegion,Count)
break
end
end
end)
while wait(1) do
if #playersInPartRegion < 3 and #playersInPartRegion > 0 then
for _, index in pairs(playersInPartRegion) do
if game.Players:FindFirstChild(index) then
local player = game.Players:FindFirstChild(index)
if player.Character then
player.Character:MoveTo(lobby.Position)
end
end
end
end
end
try this
1 Like
It still doesn’t teleport players.
local lobby = game.Workspace.LobbyTeleport
local inRound = game.ReplicatedStorage.InRound
local playersInPartRegion = {}
local playerisIn = false
game.ReplicatedStorage.AddPlayerToTable.OnServerEvent:Connect(function(PlayerToAdd)
table.insert(playersInPartRegion,PlayerToAdd.Name)
wait(1)
for _, v in pairs(playersInPartRegion) do print(v) end
end)
game.ReplicatedStorage.RemovePlayerFromTable.OnServerEvent:Connect(function(PlayerToRem)
local Count = 0
for _,index in pairs(playersInPartRegion) do
Count = Count + 1
if index == PlayerToRem.Name then
table.remove(playersInPartRegion,Count)
Count = nil
break
end
end
end)
while wait(1) do
if #playersInPartRegion < 3 and #playersInPartRegion > 0 then
for _, index in pairs(playersInPartRegion) do
if game.Players:FindFirstChild(index) then
local player = game.Players:FindFirstChild(index)
if player.Character then
player.Character:MoveTo(lobby.Position)
end
end
end
end
end
see what it prints
2 Likes
this should work:
local lobby = game.Workspace.LobbyTeleport
local inRound = game.ReplicatedStorage.InRound
local playersInPartRegion = {}
game.ReplicatedStorage.AddPlayerToTable.OnServerEvent:Connect(function(PlayerToAdd)
table.insert(playersInPartRegion,PlayerToAdd.Name)
end)
game.ReplicatedStorage.RemovePlayerFromTable.OnServerEvent:Connect(function(PlayerToRem)
if table.find(playersInPartRegion, PlayerToRem.Name) then -- or playersInPartRegion[Player.Name]
table.remove(playersInPartRegion, PlayerToRem.Name)
end
end)
while wait(5) do --delay
if #playersInPartRegion > 0 and #playersInPartRegion < 5 then ---max is 5
for _,Player in pairs(game.Players:GetPlayers()) do
if table.find(playersInPartRegion, Player.Name) then -- or playersInPartRegion[Player.Name]
print("teleporting: "..Player.Name)
local char = Player.Character or Player.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
hrp.Position = lobby.Position -- teleports
end
end
end
end
use arrays instead of dictionaries!
2 Likes
@YT_Forceman, and @HemanshuGaming, I can’t test it right now, I will test it later.
2 Likes
I don’t remember the output well because my Roblox Studio was not responding due to printing out so much, but It was something like “BattleZoneAreaPart”, and “Ojnim0702 (x580)”.
Thanks, but it seems to be not working, does this have to be in a Script or a LocalScript? Also, can you tell me where to put this?
Just to let you know, @HemanshuGaming, @YT_Forceman, this script is in ServerScriptService, and it is a script:
local lobby = game.Workspace.LobbyTeleport
local inRound = game.ReplicatedStorage.InRound
local playersInPartRegion = {}
game.ReplicatedStorage.AddPlayerToTable.OnServerEvent:Connect(function(playerToAdd)
table.insert(playersInPartRegion, playerToAdd.Name)
end)
game.ReplicatedStorage.RemovePlayerFromTable.OnServerEvent:Connect(function(playerToRem)
if table.find(playersInPartRegion, playerToRem.Name) then
table.remove(playersInPartRegion, playerToRem.Name)
end
end)
while wait(5) do
if #playersInPartRegion < 2 and #playersInPartRegion > 0 then
for _, player in pairs(game.Players:GetChildren()) do
if table.find(playersInPartRegion, player.Name) then
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
humanoidRootPart.Position = lobby.Position
end
end
end
end
and this script is a LocalScript, and it is located inside StarterGui.
local lobby = game.Workspace.LobbyTeleport
local playerisIn = false
while wait(1) do
for i, v in pairs(game.Workspace:GetChildren()) do
if v.Name == "BattleZoneAreaPart" then
playerisIn = false
local region = Region3.new(v.Position - (v.Size/2), v.Position + (v.Size/2))
local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())
for _, part in pairs(parts) do
if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
playerisIn = true
break
else
playerisIn = false
end
end
end
if playerisIn == true then
game.ReplicatedStorage.AddPlayerToTable:FireServer()
else
game.ReplicatedStorage.RemovePlayerFromTable:FireServer()
end
end
end