Pepperpants

Roblox Teleport Pad Script

Jun 18th, 2023
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. -- Configuration
  2. local teleportPart = script.Parent -- The part representing the teleport pad
  3.  
  4. -- Teleport Function
  5. local function teleportPlayer(part, player)
  6. -- Check if the part touched is the teleport pad
  7. if part == teleportPart then
  8. -- Get the desired teleport location
  9. local teleportDestination = Vector3.new(x, y, z) -- Replace x, y, z with the destination coordinates
  10.  
  11. -- Teleport the player to the destination
  12. player.Character.HumanoidRootPart.CFrame = CFrame.new(teleportDestination)
  13. end
  14. end
  15.  
  16. -- Player Touch Event
  17. local function onPlayerTouch(part)
  18. -- Get the player who touched the part
  19. local player = game.Players:GetPlayerFromCharacter(part.Parent)
  20.  
  21. -- Check if the player exists and is alive
  22. if player and player.Character and player.Character:FindFirstChild("Humanoid") and player.Character.Humanoid.Health > 0 then
  23. teleportPlayer(part, player)
  24. end
  25. end
  26.  
  27. -- Connect the touch event
  28. teleportPart.Touched:Connect(onPlayerTouch)
Advertisement
Add Comment
Please, Sign In to add comment