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:
function scriptfunnyhaha()
local intermission = 10
local roundLength = 180
local inRound = game.ReplicatedStorage.InRound
local status = game.ReplicatedStorage.Status
local playing = {}
local playingTeam = game.Teams.Playing
local playersingame = 0
local murdingamechecked = {}
local lobbyTeam = game.Teams.Lobby
local murdermodule = require(game.ReplicatedStorage.MurderModule)
inRound.Changed:Connect(function()
if inRound.Value == true then
for i, plr in pairs(game.Players:GetChildren()) do
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
plr.Team = playingTeam
char:WaitForChild("Humanoid").Died:Connect(function(playerwhodied)
plr.Team = lobbyTeam
table.remove(playing, playerwhodied)
end)
end
else
for i, plr in pairs(game.Players:GetChildren()) do
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
local human = char.Humanoid
plr.Team = lobbyTeam
human:UnequipTools()
for i, tool in pairs(plr.Backpack:GetChildren()) do
if tool.Name == "6 gold chain guns" then
else
plr.Backpack:ClearAllChildren()
end
end
end
end
end)
local function round()
while true do
local requiredPlayers = 2
repeat
wait(1)
status.Value = "Atleast ".. requiredPlayers.." players are needed to start a round"
until #game.Players:GetChildren() >= requiredPlayers
inRound.Value = false
for i = intermission, 0, -1 do
status.Value = "Game will start in "..i.." seconds"
wait(1)
end
inRound.Value = true
for i, plr in pairs(game.Players:GetChildren()) do
if plr.Team.Name == "Playing" then
table.insert(playing, plr.Name)
end
end
playersingame = #game.Players:GetPlayers()
murdermodule.ChooseRoles()
for i = roundLength, 0, -1 do
status.Value = "Game will end in "..i.." seconds"
local murdereralive = false
local nonmurderersalive = false
local murderer
print(murderer)
for i, playerInRound in pairs(playing) do
if game.Players:FindFirstChild(playerInRound) then
if game.Players:FindFirstChild(playerInRound):WaitForChild("Role").Value == "Murderer" then
murdereralive = true
murderer = game.Players:FindFirstChild(playerInRound)
print("murd is alive")
elseif game.Players:FindFirstChild(playerInRound):WaitForChild("Role").Value ~= "Murderer" then
nonmurderersalive = true
print("innocents are alive")
end
else
if murderer == playerInRound then
status.Value = "The Murderer has turned themselves in."
if game.Workspace:FindFirstChild("GunClone") then
game.Workspace.GunClone:Destroy()
if game.Workspace:FindFirstChild("GunClone") then
game.Workspace.GunClone:Destroy()
end
end
wait(3)
return scriptfunnyhaha()
end
end
end
if #playing == 0 then
status.Value = "Everyone Has Died"
if game.Workspace:FindFirstChild("GunClone") then
game.Workspace.GunClone:Destroy()
if game.Workspace:FindFirstChild("GunClone") then
game.Workspace.GunClone:Destroy()
end
end
wait(3)
return scriptfunnyhaha()
end
print(tostring(murdereralive).. "murd")
print(tostring(nonmurderersalive).. "nonmurd")
if murdereralive == true and nonmurderersalive == false then
status.Value = "The Murderer got away with their crimes."
if game.Workspace:FindFirstChild("GunClone") then
game.Workspace.GunClone:Destroy()
if game.Workspace:FindFirstChild("GunClone") then
game.Workspace.GunClone:Destroy()
end
end
wait(3)
return scriptfunnyhaha()
end
if murdereralive == false and nonmurderersalive == true then
status.Value = "The Murderer has been rightfully killed!"
if game.Workspace:FindFirstChild("GunClone") then
game.Workspace.GunClone:Destroy()
if game.Workspace:FindFirstChild("GunClone") then
game.Workspace.GunClone:Destroy()
end
end
wait(3)
return scriptfunnyhaha()
end
if nonmurderersalive == true and i == 0 then
status.Value = "The Murderer took too long and got caught."
if game.Workspace:FindFirstChild("GunClone") then
game.Workspace.GunClone:Destroy()
if game.Workspace:FindFirstChild("GunClone") then
game.Workspace.GunClone:Destroy()
end
end
wait(3)
return scriptfunnyhaha()
end
wait(1)
end
wait(3)
end
end
spawn(round)
end
scriptfunnyhaha()