Hello Developers, so in my free time i was building a map, i decided to add a portal to teleport the player to a different zone. To teleport a player i always define the torso, and then move the torso with Vector3
Example:
script.Parent.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
local Torso = Humanoid.Torso
if Torso then
Torso.Position = Vector3.new(0,0,0) -- For example
end
end)
I added a kind of transition, a simple one. I used a loop to add transparency to a frame.
Example:
local player = game:GetService("Players").LocalPlayer
local part = game.Workspace.Portal.Teleport
part.Touched:Connect(function(hit)
if hit.Parent == player.Character then
script.Parent.Visible = true
player.Character.HumanoidRootPart.Position = Vector3.new(-63.456, 58.586, 109.709)
for i = 1,20 do
wait(0.1)
script.Parent.BackgroundTransparency = script.Parent.BackgroundTransparency +0.1
end
end
end)
Here a video of what happens:
So the transition works, to record the video i just removed it, but the player glitches in the map, is there a way to move a player without glitching it?
Since the player character is a Model, you can use Model:MoveTo([pos]) which move all of the parts to a location, it also makes sure that they don’t get stuck inside other parts.