Advertisement
athaha

Test

Dec 14th, 2024
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. -- Portal 1
  2. local portal1 = game.Workspace.Portal1 -- Name of the first portal part
  3. local portal2 = game.Workspace.Portal2 -- Name of the second portal part
  4.  
  5. local destination1 = portal2.Position + Vector3.new(0, 5, 0) -- Position for Portal 1 to Portal 2
  6. local destination2 = portal1.Position + Vector3.new(0, 5, 0) -- Position for Portal 2 to Portal 1
  7.  
  8. -- Function to teleport players when they touch the portals
  9. local function onPortalTouched(portal, destination)
  10. portal.Touched:Connect(function(hit)
  11. local character = hit.Parent
  12. local player = game.Players:GetPlayerFromCharacter(character)
  13.  
  14. if player then
  15. -- Teleport the player's character
  16. local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
  17. if humanoidRootPart then
  18. humanoidRootPart.CFrame = CFrame.new(destination)
  19. end
  20. end
  21. end)
  22. end
  23.  
  24. -- Set up teleportation between portals
  25. onPortalTouched(portal1, destination1)
  26. onPortalTouched(portal2, destination2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement