Advertisement
Bearium

People Manager

Jan 9th, 2025 (edited)
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | Source Code | 0 0
  1. -- Script Parent
  2. local Teleporter = script.Parent
  3.  
  4. -- Teleporter Parts
  5. local enterPart = Teleporter.Enter
  6. local enterPos  = Teleporter.EnterPosition
  7. local exitPart  = Teleporter.Exit
  8. local exitPos   = Teleporter.ExitPosition
  9.  
  10. -- Players waiting to join & Place ID
  11. local currentPlayers = Teleporter.CurrentPlayers
  12. local PlaceID = 1234567890 -- !!ENTER YOUR PLACE ID HERE!!
  13.  
  14. -- Check if the User exists and if not then create "String Instance"
  15. local function CreatePlayer(playerName)
  16.     for _, player in pairs(currentPlayers:GetChildren()) do
  17.         if player:IsA("StringValue") and player.Value == playerName then
  18.             return false
  19.         end
  20.     end
  21.    
  22.     local player = Instance.new("StringValue")
  23.     player.Name = "Player"
  24.     player.Value = playerName
  25.     player.Parent = currentPlayers
  26. end
  27.  
  28. -- Add to Current Players
  29. local function AddCurrent(player)
  30.     if player and player:IsA("Player") then
  31.         CreatePlayer(player.Name)
  32.         player.Character.HumanoidRootPart.CFrame = enterPos.CFrame
  33.     end
  34. end
  35.  
  36. -- Remove from Current Players
  37. local function RemoveCurrent(player)
  38.     for _, child in pairs(currentPlayers:GetChildren()) do
  39.         if child:IsA("StringValue") and child.Value == player.Name then
  40.             player.Character.HumanoidRootPart.CFrame = exitPos.CFrame
  41.             child:Destroy()
  42.             break
  43.         end
  44.     end
  45. end
  46.  
  47. enterPart.Touched:Connect(function(hit)
  48.     local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  49.     if player then
  50.         AddCurrent(player)
  51.     end
  52. end)
  53.  
  54. exitPart.Touched:Connect(function(hit)
  55.     local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  56.     if player then
  57.         RemoveCurrent(player)
  58.     end
  59. end)
Tags: lua
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement