So basically, I’m trying to make a teleport system, but it only teleports one person. What is going on???
-- part1
game.ReplicatedStorage.Te:FireAllClients()
-- part2
game.ReplicatedStorage.OnServerEvent:Connect(function()
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = game.Workspace:WaitForChild("LoadedMap").SpawnPlayersToMap.CFrame
end
end)
EDIT: Ok so I know why this isn’t working… I think I know the solution now, let me solve it…
for _, player in pairs(game.Players:GetPlayers()) do
local char = player.Character
char.HumanoidRootPart.CFrame = game.Workspace:WaitForChild("LoadedMap").SpawnPlayersToMap.CFrame
end
local playerName = "playerNameHere" -- recommend using userid
for _, player in pairs(game.Players:GetPlayers()) do
if player.Name == playerName then
player.Character.HumanoidRootPart.CFrame = game.Workspace:WaitForChild("LoadedMap").SpawnPlayersToMap.CFrame
end
end
for _, player in pairs(game.Players:GetPlayers()) do
player.Character.HumanoidRootPart.CFrame = game.Workspace:WaitForChild("LoadedMap").SpawnPlayersToMap.CFrame
end
for _, player in pairs(game.Players:GetPlayers()) do
player.Character.HumanoidRootPart.CFrame = workspace:WaitForChild("LoadedMap").SpawnPlayersToMap.CFrame
end
'''
for i,v in next, game.Players:GetPlayers() do
if v.Character then
v.Character.HumanoidRootPart.CFrame = workspace:WaitForChild("LoadedMap").SpawnPlayersToMap.CFrame
end
end
'''
Use this tutorial provided by Roblox itself on how to teleport every player within a game to a specific location:
If you’re still having issues then you’re more than likely doing something wrong.
P.S. Before coming to Scripting Support for something, I suggest to first investigate it on https://developer.roblox.com since they have tons of tutorials to teach devs learning the ways of scripting.
Wait I think I know why… So basically, this teleport thing is in a round script, and I put all of the ends at the bottom so that the code runs, and them repeats again. (I put a while true do loop at the top so it loops)