Advertisement
Cakey3101

Portal Script In Portal

May 2nd, 2025
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | Source Code | 0 0
  1. local Players = game:GetService("Players")
  2.  
  3. local Portal = script.Parent
  4. local PlaceToBeTeleported = Portal.PlaceToBeTeleported
  5.  
  6. local function Debounce(Function)
  7.     local IsRunning = false
  8.     return function(Hit)
  9.         if not IsRunning then
  10.             IsRunning = true
  11.             Function(Hit)
  12.             IsRunning = false
  13.         end
  14.     end
  15. end
  16.  
  17. Portal.Touched:Connect(Debounce(function(Hit)
  18.     local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
  19.    
  20.     if Humanoid then
  21.         local Character = Hit.Parent
  22.         local Player = Players:GetPlayerFromCharacter(Character)
  23.        
  24.         if Player then
  25.             local RebirthsValue = Player:WaitForChild("leaderstats"):WaitForChild("Rebirth")
  26.            
  27.             if RebirthsValue.Value >= Portal.RebirthsRequired.Value then
  28.                 Character:PivotTo(PlaceToBeTeleported.CFrame)
  29.             end
  30.         end
  31.     end
  32. end))
Tags: robloxstudio
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement