Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script Parent
- local Teleporter = script.Parent
- -- Teleporter Parts
- local enterPart = Teleporter.Enter
- local enterPos = Teleporter.EnterPosition
- local exitPart = Teleporter.Exit
- local exitPos = Teleporter.ExitPosition
- -- Players waiting to join & Place ID
- local currentPlayers = Teleporter.CurrentPlayers
- local PlaceID = 1234567890 -- !!ENTER YOUR PLACE ID HERE!!
- -- Check if the User exists and if not then create "String Instance"
- 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
- -- Add to Current Players
- local function AddCurrent(player)
- if player and player:IsA("Player") then
- CreatePlayer(player.Name)
- player.Character.HumanoidRootPart.CFrame = enterPos.CFrame
- end
- end
- -- Remove from Current Players
- 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)
- end
- end)
- exitPart.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player then
- RemoveCurrent(player)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement