Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --https://youtu.be/rvva4TSGunI
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Workspace = game:GetService("Workspace")
- -- Setup shared value
- local chosenPlayerValue = ReplicatedStorage:FindFirstChild("ChosenPlayer")
- if not chosenPlayerValue then
- chosenPlayerValue = Instance.new("StringValue")
- chosenPlayerValue.Name = "ChosenPlayer"
- chosenPlayerValue.Parent = ReplicatedStorage
- end
- -- Setup spawn parts
- local chosenSpawn = Workspace:FindFirstChild("ChosenSpawn") or Instance.new("Part", Workspace)
- chosenSpawn.Size = Vector3.new(6, 1, 6)
- chosenSpawn.Position = Vector3.new(50, 3, 100)
- chosenSpawn.Anchored = true
- chosenSpawn.BrickColor = BrickColor.new("Bright green")
- chosenSpawn.Name = "ChosenSpawn"
- local otherSpawn = Workspace:FindFirstChild("OtherSpawn") or Instance.new("Part", Workspace)
- otherSpawn.Size = Vector3.new(6, 1, 6)
- otherSpawn.Position = Vector3.new(-50, 3, 100)
- otherSpawn.Anchored = true
- otherSpawn.BrickColor = BrickColor.new("Bright red")
- otherSpawn.Name = "OtherSpawn"
- -- Pick one random player and teleport
- local function chooseRandomPlayer()
- local playerList = Players:GetPlayers()
- if #playerList == 0 then return end
- local chosenPlayer = playerList[math.random(1, #playerList)]
- chosenPlayerValue.Value = "Chosen Player: " .. chosenPlayer.Name
- if chosenPlayer.Character then
- chosenPlayer.Character:MoveTo(chosenSpawn.Position)
- end
- for _, player in pairs(playerList) do
- if player ~= chosenPlayer and player.Character then
- player.Character:MoveTo(otherSpawn.Position)
- end
- end
- end
- task.wait(10)
- chooseRandomPlayer()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement