Advertisement
OnFireRobloxScriptin

Teleport Portal Script

Sep 10th, 2024
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. --//Variables
  2. local TeleportService = game:GetService("TeleportService") --Variable for Teleport Service
  3. local Players = game:GetService("Players") --Variable for Players
  4. local gameId = 6651677874 --Replace this number with your game ID
  5. local db = true --Debounce
  6. local teleportpart = script.Parent --Variable for our teleport part
  7.  
  8. --//Teleport
  9. teleportpart.Touched:Connect(function(hit) --When the teleport part is touched
  10.     if hit and hit.Parent:FindFirstChild("Humanoid") then --Check if it is a character (characters have humanoids in them)
  11.         if db then --If it is a character, check if the debounc is true
  12.             db = false --If it is true, set it to false
  13.             local player = Players:GetPlayerFromCharacter(hit.Parent) --Retrieves the player from the character
  14.             TeleportService:Teleport(gameId, player) --Teleport the player to the game
  15.             db = true --Sets the debounce back to true so other players can teleport too
  16.         end
  17.     end
  18. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement