local re = game.ReplicatedStorage.RemoteEvents local values = game.ReplicatedStorage.Values local nl = 1 local function randomP() local players = game.Workspace.PlayerTest:GetChildren() local PlayerNum = math.random(1, #players) local ChosenPlayer = players[PlayerNum] print(ChosenPlayer) values.CanStart.Value = true values.NextUp.Value = ChosenPlayer.Name values.NextName.Value = ChosenPlayer.Name end local function clear() values.Value.Value = true values.PlayerValue.Value = "" values.NValue.Value = 0 values.YValue.Value = 0 values.NameValue.Value = "" values.CanStart.Value = false end repeat re.TimerEvent:FireAllClients(false, values.NextUp.Value, 0, "", values.Players.Value) wait() until values.Players.Value >= 2 wait(10) local function G() print("Okay") values.Value.Value = false values.PlayerValue.Value = values.NextUp.Value values.NameValue.Value = values.NextName.Value game.Workspace.Helicopter.Main.SurfaceGui1.Back.Text = "Decide "..values.NextUp.Value.."'s fate!" game.Workspace.Helicopter.Main.SurfaceGui.Front.Text = "Decide "..values.NextUp.Value.."'s fate!" if values.NameValue.Value ~= "" then --game.Players:FindFirstChild(values.NextName.Value).Character:FindFirstChild("HumanoidRootPart").CFrame = game.Workspace.TPart.CFrame end randomP() re.TimerEvent:FireAllClients(true, values.NextUp.Value, 30, "Next Up:") re.VoteEvent:FireAllClients(values.PlayerValue.Value) wait(30) if values.NValue.Value > values.YValue.Value then if values.NameValue.Value ~= "" then if game.Players:FindFirstChild(values.NameValue.Value).HasAvoid.Value == false then --game.Players:FindFirstChild(values.NameValue.Value):Kick("Kicked by majority") re.CloseEvent:FireAllClients(values.PlayerValue.Value, "Kick") else game.Players:FindFirstChild(values.NameValue.Value).HasAvoid.Value = false re.BuyEvent:FireClient(game.Players:FindFirstChild(values.NameValue.Value), "not") --game.Workspace:FindFirstChild(values.NameValue.Value).HumanoidRootPart.Position = game.Workspace.SpawnLocation.Position end end end if values.NValue.Value <= values.YValue.Value then if values.NameValue.Value ~= "" then re.CloseEvent:FireAllClients(values.PlayerValue.Value, "Stay") --game.Workspace:FindFirstChild(values.NameValue.Value).HumanoidRootPart.Position = game.Workspace.SpawnLocation.Position end end wait(3) clear() end while true do if values.Value.Value == true then G() end end
Right now since I dont have many people to help test I have 3 parts to fill in as the players
Maybe this will work for you?
Just so you know if you are the only one in the server it will keep trying to pick a new player but can't since you're the only
local re = game.ReplicatedStorage.RemoteEvents local values = game.ReplicatedStorage.Values local nl = 1 local lastChosenPlayer = nil local function randomP() local players = game.Workspace.PlayerTest:GetChildren() local PlayerNum = math.random(1, #players) local ChosenPlayer = players[PlayerNum] if ChosenPlayer == LastChosenPlayer then print("same player, choosing a new one") randomP() else print(ChosenPlayer) values.CanStart.Value = true values.NextUp.Value = ChosenPlayer.Name values.NextName.Value = ChosenPlayer.Name end end local function clear() values.Value.Value = true values.PlayerValue.Value = "" values.NValue.Value = 0 values.YValue.Value = 0 values.NameValue.Value = "" values.CanStart.Value = false end repeat re.TimerEvent:FireAllClients(false, values.NextUp.Value, 0, "", values.Players.Value) wait() until values.Players.Value >= 2 wait(10) local function G() print("Okay") values.Value.Value = false values.PlayerValue.Value = values.NextUp.Value values.NameValue.Value = values.NextName.Value game.Workspace.Helicopter.Main.SurfaceGui1.Back.Text = "Decide "..values.NextUp.Value.."'s fate!" game.Workspace.Helicopter.Main.SurfaceGui.Front.Text = "Decide "..values.NextUp.Value.."'s fate!" if values.NameValue.Value ~= "" then --game.Players:FindFirstChild(values.NextName.Value).Character:FindFirstChild("HumanoidRootPart").CFrame = game.Workspace.TPart.CFrame end randomP() re.TimerEvent:FireAllClients(true, values.NextUp.Value, 30, "Next Up:") re.VoteEvent:FireAllClients(values.PlayerValue.Value) wait(30) if values.NValue.Value > values.YValue.Value then if values.NameValue.Value ~= "" then if game.Players:FindFirstChild(values.NameValue.Value).HasAvoid.Value == false then --game.Players:FindFirstChild(values.NameValue.Value):Kick("Kicked by majority") re.CloseEvent:FireAllClients(values.PlayerValue.Value, "Kick") else game.Players:FindFirstChild(values.NameValue.Value).HasAvoid.Value = false re.BuyEvent:FireClient(game.Players:FindFirstChild(values.NameValue.Value), "not") --game.Workspace:FindFirstChild(values.NameValue.Value).HumanoidRootPart.Position = game.Workspace.SpawnLocation.Position end end end if values.NValue.Value <= values.YValue.Value then if values.NameValue.Value ~= "" then re.CloseEvent:FireAllClients(values.PlayerValue.Value, "Stay") --game.Workspace:FindFirstChild(values.NameValue.Value).HumanoidRootPart.Position = game.Workspace.SpawnLocation.Position end end wait(3) clear() end while true do if values.Value.Value == true then G() end end