Guest User

People Manager

a guest
Jan 11th, 2025
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | Source Code | 0 0
  1. local Players = game:GetService("Players")
  2.  
  3. local Teleporter = script.Parent
  4.  
  5. local enterPart = Teleporter.Enter
  6. local enterPos  = Teleporter.EnterPosition
  7. local exitPart  = Teleporter.Exit
  8. local exitPos   = Teleporter.ExitPosition
  9.  
  10. local currentPlayers = Teleporter.CurrentPlayers
  11. local PlaceID = 81956029110985
  12.  
  13. enterPart.BillboardGui.Players.Text = "" .. #currentPlayers:GetChildren() .. "/".. 30 ..""
  14.  
  15. local function EditGUIText()
  16.     enterPart.BillboardGui.Players.Text = "" .. tostring(#currentPlayers:GetChildren()) .. "/".. 30 ..""
  17. end
  18.  
  19. local function CreatePlayer(playerName)
  20.     for _, player in pairs(currentPlayers:GetChildren()) do
  21.         if player:IsA("StringValue") and player.Value == playerName then
  22.             return false
  23.         end
  24.     end
  25.  
  26.     local player = Instance.new("StringValue")
  27.     player.Name = "Player"
  28.     player.Value = playerName
  29.     player.Parent = currentPlayers
  30. end
  31.  
  32. local function AddCurrent(player)
  33.     if player and player:IsA("Player") then
  34.         CreatePlayer(player.Name)
  35.         EditGUIText()
  36.  
  37.         local humRP = player.Character.HumanoidRootPart
  38.         if humRP then
  39.             humRP.CFrame = enterPos.CFrame
  40.         end
  41.     end
  42. end
  43.  
  44. local function RemoveCurrent(player)
  45.     for _, child in pairs(currentPlayers:GetChildren()) do
  46.         if child:IsA("StringValue") and child.Value == player.Name then
  47.             child:Destroy()
  48.             EditGUIText()
  49.  
  50.             local humRP = player.Character.HumanoidRootPart
  51.             if humRP then
  52.                 humRP.CFrame = exitPos.CFrame
  53.             end
  54.             break
  55.         end
  56.     end
  57. end
  58.  
  59. enterPart.Touched:Connect(function(hit)
  60.     local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  61.     if player then
  62.         AddCurrent(player)
  63.     end
  64. end)
  65.  
  66. exitPart.Touched:Connect(function(hit)
  67.     local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  68.     if player then
  69.         RemoveCurrent(player)
  70.     end
  71. end)
  72.  
  73. Players.PlayerRemoving:Connect(function(Player)
  74.     RemoveCurrent(Player)
  75. end)
Add Comment
Please, Sign In to add comment