Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Teleporter = script.Parent
- local enterPart = Teleporter.Enter
- local enterPos = Teleporter.EnterPosition
- local exitPart = Teleporter.Exit
- local exitPos = Teleporter.ExitPosition
- local currentPlayers = Teleporter.CurrentPlayers
- local PlaceID = 81956029110985
- enterPart.BillboardGui.Players.Text = "" .. #currentPlayers:GetChildren() .. "/".. 30 ..""
- local function CreatePlayer(playerName)
- for _, player in pairs(currentPlayers:GetChildren()) do
- if player:IsA("StringValue") and player.Value == playerName then
- return false
- end
- end
- local player = Instance.new("StringValue")
- player.Name = "Player"
- player.Value = playerName
- player.Parent = currentPlayers
- end
- local function AddCurrent(player)
- if player and player:IsA("Player") then
- CreatePlayer(player.Name)
- player.Character.HumanoidRootPart.CFrame = enterPos.CFrame
- end
- end
- local function RemoveCurrent(player)
- for _, child in pairs(currentPlayers:GetChildren()) do
- if child:IsA("StringValue") and child.Value == player.Name then
- player.Character.HumanoidRootPart.CFrame = exitPos.CFrame
- child:Destroy()
- break
- end
- end
- end
- enterPart.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player then
- AddCurrent(player)
- enterPart.BillboardGui.Players.Text = "" .. #currentPlayers:GetChildren() .. "/".. 30 ..""
- end
- end)
- exitPart.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player then
- RemoveCurrent(player)
- enterPart.BillboardGui.Players.Text = "" .. #currentPlayers:GetChildren() .. "/".. 30 ..""
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement