I’m currently making a game where two random players are picked and then they debate the topic, then the other players vote on who won. Basically a rap battle game almost. But when the 2 players are teleported only one gets teleported to the blue square. I think this is because it’s picking the same person twice as each participant, but I don’t know how to fix it. Any ideas?
--//SETTINGS
Min_Players = 3
Time_Per_Speak = 30
Possible_Debates = {
"Should Icy advertise?",
"Are you sussy?",
"Does 9+10 = 21?"
}
--//VARIABLES
local Player_Service = game.Players
--//CODE
while task.wait() do
repeat
task.wait()
if #Player_Service:GetPlayers() >= Min_Players then
end
until #Player_Service:GetPlayers() >= Min_Players
local RedTeam
print("redteam")
repeat
task.wait()
print("ok")
RedTeam = Player_Service:GetPlayers()[math. random(1, #Player_Service:GetPlayers())]
local Cant_Be_Picked = Instance.new("BoolValue")
Cant_Be_Picked.Parent = RedTeam
Cant_Be_Picked.Name = "DeleteLater"
until RedTeam ~= nil
local BlueTeam
repeat
task.wait()
BlueTeam = Player_Service:GetPlayers()[math. random(1, #Player_Service:GetPlayers())]
if BlueTeam:FindFirstChild("DeleteLater") ~= nil then
BlueTeam:FindFirstChild("DeleteLater"):Destroy()
print("blue")
else
BlueTeam = nil
end
until BlueTeam ~= nil
local RedCharacter = RedTeam.Character
local BlueCharacter = BlueTeam.Character
RedCharacter.Humanoid.WalkSpeed = 0
BlueCharacter.Humanoid.WalkSpeed = 0
RedCharacter.HumanoidRootPart.CFrame = workspace.RedTeam.CFrame + Vector3.new(0,3,0)
BlueCharacter.HumanoidRootPart.CFrame = workspace.BlueTeam.CFrame + Vector3.new(0,3,0)
local Debate = Possible_Debates[math.random(1,#Possible_Debates)]
local Turn
game.ReplicatedStorage.SetDebateTopic:FireAllClients(Debate)
RedTeam.Chatted:Connect(function(Chat)
if Turn == "Red" then
local FilteredInstance = game:GetService("TextService"):FilterStringAsync(Chat, RedTeam.UserID, Enum.TextFilterContext.PublicChat)
local FilteredString = FilteredInstance:GetNonChatStringForUserAsync(RedTeam.UserID)
game.ReplicatedStorage.UpdateUis:FireAllClients(FilteredString)
end
end)
BlueTeam.Chatted:Connect(function(Chat)
if Turn == "Blue" then
local FilteredInstance = game:GetService("TextService"):FilterStringAsync(Chat, BlueTeam.UserID, Enum.TextFilterContext.PublicChat)
local FilteredString = FilteredInstance:GetNonChatStringForUserAsync(BlueTeam.UserID)
game.ReplicatedStorage.UpdateUis:FireAllClients(FilteredString)
end
end)
Turn = "Red"
task.wait(Time_Per_Speak)
Turn = "Blue"
task.wait(Time_Per_Speak)
Turn = "Red"
task.wait(Time_Per_Speak)
Turn = "Blue"
task.wait(Time_Per_Speak)
Turn = "Red"
task.wait(Time_Per_Speak)
Turn = "Blue"
task.wait(Time_Per_Speak)
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local redcontent, isReady = game.Players:GetUserThumbnailAsync(RedTeam.UserId, thumbType, thumbSize)
local bluecontent, isReady = game.Players:GetUserThumbnailAsync(BlueTeam.UserId, thumbType, thumbSize)
game.ReplicatedStorage.SetPictures:FireAllClients(redcontent, bluecontent)
task.wait(10)
RedCharacter.Humanoid.Health = 0
BlueCharacter.Humanoid.Health = 0
RedTeam = nil
BlueTeam = nil
RedCharacter = nil
BlueCharacter = nil
redcontent = nil
bluecontent = nil
Debate = nil
Turn = nil
end