So basically I made a Murder Mystery script but sometimes the wrong side wins. Example: The murderer dies but then the murderer wins. Another example: The murderer kills everyone but then the murderer loses
I ofc can’t find anything on the devforum cause yk. Also I tried on my own.
heres my script:
local murdersystem = {} function murdersystem.ChooseRoles() local players = game:GetService("Players") local playersingame = {} local Teams = game:GetService("Teams") local teamPlayers = Teams["Playing"]:GetPlayers() for i, p in pairs(players:GetChildren()) do table.insert(playersingame, p.Name) end if #playersingame >= 1 then local murderer = playersingame[math.random(1, #playersingame)] table.remove(playersingame, table.find(playersingame, murderer)) players:FindFirstChild(murderer):WaitForChild("Role").Value = "Murderer" local sherrif = playersingame[math.random(1, #playersingame)] table.remove(playersingame, table.find(playersingame, sherrif)) players:FindFirstChild(sherrif):WaitForChild("Role").Value = "Detective" for i, plrname in pairs(playersingame) do players:FindFirstChild(plrname):WaitForChild("Role").Value = "Witness" end wait(5) for i, playerInRound in pairs(players:GetChildren()) do if playerInRound.Team.Name == "Playing" then game.ReplicatedStorage.DisplayRole:FireClient(playerInRound) end end wait(5) local knifeclone = game.ReplicatedStorage.Knife:Clone() if players:FindFirstChild(murderer) then knifeclone.Parent = players:FindFirstChild(murderer).Backpack print("gave knife to ".. murderer) end local gunclone = game.ReplicatedStorage.Gun:Clone() if players:FindFirstChild(sherrif) then gunclone.Parent = players:FindFirstChild(sherrif).Backpack print("gave gun to ".. sherrif) end return murderer else return "Not Enough Players" end end return murdersystem