Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my player teleport not working?

Even though character collision is turned off when I teleport players instead of putting all players at a coordinate (ex. -1179.999, 0.5, -645) it drops them mid air any idea why this happens?

The characters will eventually drop to the spawn location however if the players are moved to a room some will spawn on the roof instead of the spawn location.

See an example of what I am talking about: https://tinyurl.com/TeleportGlitch

p = game.Players:GetChildren()	
for i = 1, #p do
	p[i].Character:MoveTo(Vector3.new(1179.999, 0.5, -645))
end

2 answers

✓ Accepted answer

You can directly set the CFrame instead of using MoveTo. This might work:

p[i].Character.HumanoidRootPart.CFrame = CFrame.new(1178, 0.5, -645) -- I rounded the X axis

1 comment

0

This worked perfectly! Thank you so much.

I'm guessing that you just set all the parts inside of the players to 'CanCollide = false', this does not work and if you are teleporting all of your players on the same spot, they will start stacking on top of each other.

I would suggest using Collision Groups to make it so your players do not collide.

Here is a sample code (from the Roblox dev website) and a link to the detailed tutorial

local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")
 
local playerCollisionGroupName = "Players"
PhysicsService:CreateCollisionGroup(playerCollisionGroupName)
PhysicsService:CollisionGroupSetCollidable(playerCollisionGroupName, playerCollisionGroupName, false)
 
local previousCollisionGroups = {}
 
local function setCollisionGroup(object)
  if object:IsA("BasePart") then
    previousCollisionGroups[object] = object.CollisionGroupId
    PhysicsService:SetPartCollisionGroup(object, playerCollisionGroupName)
  end
end
 
local function setCollisionGroupRecursive(object)
  setCollisionGroup(object)
 
  for _, child in ipairs(object:GetChildren()) do
    setCollisionGroupRecursive(child)
  end
end
 
local function resetCollisionGroup(object)
  local previousCollisionGroupId = previousCollisionGroups[object]
  if not previousCollisionGroupId then return end 
 
  local previousCollisionGroupName = PhysicsService:GetCollisionGroupName(previousCollisionGroupId)
  if not previousCollisionGroupName then return end
 
  PhysicsService:SetPartCollisionGroup(object, previousCollisionGroupName)
  previousCollisionGroups[object] = nil
end
 
local function onCharacterAdded(character)
  setCollisionGroupRecursive(character)
 
  character.DescendantAdded:Connect(setCollisionGroup)
  character.DescendantRemoving:Connect(resetCollisionGroup)
end
 
local function onPlayerAdded(player)
  player.CharacterAdded:Connect(onCharacterAdded)
end
 
Players.PlayerAdded:Connect(onPlayerAdded)

This discussion is preserved as it was. New answers, comments, and votes are closed.