Portal kills me when i enter it

So i created portals and i input a script in them. But for some reason it kills me when i step in it, this is the script for both parts.

script.Parent.Touched:Connect(function(hit)
local player = hit.Parent
if player then
local torso = player.HumanoidRootPart
if torso then
torso.Position = Vector3.new(44.5, 111, 30)
end
end
end)

Updating the Position property disregards any and all welds (or more specifically Motor6D joints) a character has, thus killing them.

To teleport a character, you need to update its CFrame.

torso.CFrame = CFrame.new(44.5, 111, 30)

If you want to preserve the orientation of character body (same as they entered the portal) use:

torso.CFrame = torso.CFrame - torso.Position + Vector3.new(44.5, 111, 30)
3 Likes

You should always use CFrame when moving the HumanoidRootPart. Setting the vector3 only moves the HumanoidRootPart and not the rest of the character.

Just Move the Character Model using Model:MoveTo()

local hum = hit.Parent:FindFirstChild("Humanoid") -- to ensure the item is a character model by getting the Humanoid

if hum then -- if the Humanoid Exists
    hum.Parent:MoveTo(Vector3.new(44.5, 111, 30)) -- moves Model which is their character
end