So basically, I am trying to code a role picker. There is one person chosen to be a werewolf, one person chosen to be a villager, one person chosen to be a clairvoyant, one person chosen to be a witch, one person chosen to be a jester and one person chosen to be a clown. I also want to make it so that there is only one person per role, no one can have the same role as the other. Everything in this script works except for the role picker (at the bottom of the script). Can anybody help me? Here is the whole script that I have made:
--Variables
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local Status = game.ReplicatedStorage.Status
--Script
while true do
Status.Value = "Waiting for enough players to play"
repeat wait(1) until game.Players.NumPlayers >= 2
Status.Value = "Intermission"
wait(30)
Status.Value = "Get ready!"
wait(4)
local plrs = {}
for i, player in pairs(game.Players:GetPlayers()) do
if player then
table.insert(plrs,player) -- Add each player into plrs table
end
end
local GameZone = game.Workspace.GameZone
local ClonedGameZone = GameZone:Clone()
ClonedGameZone.Parent = workspace
--Teleporting players to the gamezone
local Seats = ClonedGameZone:FindFirstChild("Seats")
if not Seats then
print("Seats not found")
end
local AvailableSeats = Seats:GetChildren()
for i, player in pairs(plrs) do
if player then
character = player.Character
if character then
-- Teleport them
character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSeats[1].CFrame + Vector3.new(0,10,0)
table.remove(AvailableSeats,1)
character.Humanoid.WalkSpeed = 0
character.Humanoid.JumpPower = 0
local GameTag = Instance.new("BoolValue")
GameTag.Name = "GameTag"
GameTag.Parent = player.Character
else
-- There is no character
if not player then
table.remove(plrs,i)
end
end
end
end
wait(4)
if #plrs == 2 then
Status.Value = "Choosing roles.."
wait(1)
local Enemies = {}
local Allies = {}
local Neutrals = {}
local WerewolfNumber = math.random(1, #plrs)
local Werewolf = #plrs[WerewolfNumber]
table.remove(plrs,WerewolfNumber)
WerewolfNumber.PlayerGui.MainFrame.Visible = true
WerewolfNumber.PlayerGui.MainFrame.Role.Text = "A WEREWOLF"
WerewolfNumber.PlayerGui.MainFrame.Role.TextColor3 = Color3.fromRGB(203, 0, 4)
WerewolfNumber.PlayerGui.MainFrame.Description.Text = "You are an enemy. You can kill anyone except your teammate: the Clown. Blend in with the allies to not look suspicious, try not to get voted out and win by killing all allies until there is one left. Good luck."
table.insert(Enemies,WerewolfNumber)
local ClownNumber = math.random(1, #plrs)
local Clown = #plrs[ClownNumber]
table.remove(plrs,ClownNumber)
ClownNumber.PlayerGui.MainFrame.Visible = true
ClownNumber.PlayerGui.MainFrame.Role.Text = "A CLOWN"
ClownNumber.PlayerGui.MainFrame.Role.TextColor3 = Color3.fromRGB(253, 102, 8)
ClownNumber.PlayerGui.MainFrame.Description.Text = "You are an enemy. Only once in the whole game, you can kill anyone, except for your teammate: the Werewolf, when it's their turn to play. Blend in with the allies to not look suspicious, try not to get voted out and win by killing all allies until there is one left. Good luck."
table.insert(Enemies,ClownNumber)
local VillagerNumber = math.random(1, #plrs)
local Villager = #plrs[VillagerNumber]
table.remove(plrs,VillagerNumber)
VillagerNumber.PlayerGui.MainFrame.Visible = true
VillagerNumber.PlayerGui.MainFrame.Role.Text = "A VILLAGER"
VillagerNumber.PlayerGui.MainFrame.Role.TextColor3 = Color3.fromRGB(206, 205, 134)
VillagerNumber.PlayerGui.MainFrame.Description.Text = "You are an ally. You do not have a turn to play during the night so you cannot do anything. However, your goal is to try to vote out the enemies (the Werewolf and the Clown). Good luck."
table.insert(Allies,VillagerNumber)
local JesterNumber = math.random(1, #plrs)
local Jester = #plrs[JesterNumber]
table.remove(plrs,JesterNumber)
JesterNumber.PlayerGui.MainFrame.Visible = true
JesterNumber.PlayerGui.MainFrame.Role.Text = "A JESTER"
JesterNumber.PlayerGui.MainFrame.Role.TextColor3 = Color3.fromRGB(4, 61, 206)
JesterNumber.PlayerGui.MainFrame.Description.Text = "You are neutral. Your goal is to get voted out. However, you don't win when you get killed. Act suspicious and blend in with the enemies. Good luck."
table.insert(Neutrals,JesterNumber)
local WitchNumber = math.random(1, #plrs)
local Witch = #plrs[WitchNumber]
table.remove(plrs,WitchNumber)
WitchNumber.PlayerGui.MainFrame.Visible = true
WitchNumber.PlayerGui.MainFrame.Role.Text = "A WITCH"
WitchNumber.PlayerGui.MainFrame.Role.TextColor3 = Color3.fromRGB(80, 0, 206)
WitchNumber.PlayerGui.MainFrame.Description.Text = "You are an ally. After the werewolves have killed someone, you can either revive the victim with your reviving potion that you can use only once in the entire game, kill someone other than the victim with your killing potion that you can use only once in the entire game, or not do anything. Try to vote out the enemies. Good luck."
table.insert(Allies,WitchNumber)
local ClairvoyantNumber = math.random(1, #plrs)
local Clairvoyant = #plrs[ClairvoyantNumber]
table.remove(plrs,ClairvoyantNumber)
ClairvoyantNumber.PlayerGui.MainFrame.Visible = true
ClairvoyantNumber.PlayerGui.MainFrame.Role.Text = "A CLAIRVOYANT"
ClairvoyantNumber.PlayerGui.MainFrame.Role.TextColor3 = Color3.fromRGB(252, 0, 215)
ClairvoyantNumber.PlayerGui.MainFrame.Description.Text = "You are an ally. When it's your turn to play during the night, you can choose someone to see their role, so choose wisely. Try to vote out the enemies. Good luck."
table.insert(Allies,ClairvoyantNumber)
end
end
