So i made a basic teleporter, but it just makes the player's humanoidrootpart teleport, leaving behind the player's playermodel. any help?
script.Parent.Touched:Connect(function(toucher) if toucher.Parent:FindFirstChild("Humanoid") then if script.Parent.BrickColor ~= BrickColor.Green() then while true do wait() end else local teleportB = script.Parent.Parent.TelePartB toucher.Parent.HumanoidRootPart.Position = Vector3.new(teleportB.Position.X, teleportB.Position.Y + 5, teleportB.Position.Z) end end end)
CFrame
, not Position
.CFrame
description by ROBLOX:
CFrame
, is a data type that represents a position and orientation in 3D space.BasePart
have a property named CFrame
of this type. This property defines where the object is (its position), and how it is rotated (its orientation). The position information is also shown in the Position
property, and the rotation information is shown in the Rotation
property.while
loop there? Code written after, but not in the loop won't run until it breaks. I saw it as redundant so I removed it.script.Parent.Touched:Connect(function(toucher) if toucher.Parent:FindFirstChild("Humanoid") then if script.Parent.BrickColor ~= BrickColor.Green() then -- do something else local teleportB = script.Parent.Parent.TelePartB toucher.Parent:SetPrimaryPartCFrame( CFrame.new( Vector3.new( teleportB.Position.X, teleportB.Position.Y + 5, teleportB.Position.Z ) ) ) end end end)
Instead of using positions, use CFrame:
script.Parent.Touched:Connect(function(toucher) if toucher.Parent:FindFirstChild("Humanoid") then if script.Parent.BrickColor ~= BrickColor.Green() then while true do wait() end else local teleportB = script.Parent.Parent.TelePartB toucher.Parent.HumanoidRootPart.CFrame = CFrame.new(teleportB.Position.X, teleportB.Position.Y + 5, teleportB.Position.Z) end end end)
Don't Use Vector3 For teleporting things because Vector3 doesn't like it when you try and teleport INTO things so it moves it up so that might have been causing the teleport not to work properly. On the other hand CFrame works with this It allows the part go into other parts instead of above it.
CFrame.new(teleportB.Position.X, teleportB.Position.Y + 5, teleportB.Position.Z)
This should work.