Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Portal 1
- local portal1 = game.Workspace.Portal1 -- Name of the first portal part
- local portal2 = game.Workspace.Portal2 -- Name of the second portal part
- local destination1 = portal2.Position + Vector3.new(0, 5, 0) -- Position for Portal 1 to Portal 2
- local destination2 = portal1.Position + Vector3.new(0, 5, 0) -- Position for Portal 2 to Portal 1
- -- Function to teleport players when they touch the portals
- local function onPortalTouched(portal, destination)
- portal.Touched:Connect(function(hit)
- local character = hit.Parent
- local player = game.Players:GetPlayerFromCharacter(character)
- if player then
- -- Teleport the player's character
- local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
- if humanoidRootPart then
- humanoidRootPart.CFrame = CFrame.new(destination)
- end
- end
- end)
- end
- -- Set up teleportation between portals
- onPortalTouched(portal1, destination1)
- onPortalTouched(portal2, destination2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement