Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How to make murder, sheriff and innocent?

Asked by 10 years ago
        players = game.Players:GetChildren()
        local randomp = players[math.random(1,#players)]
        print(randomp.Name .. " is murderer")
        local randoms = players[math.random(1,#players)]
        print(randoms.Name .. " is sheriff")
        for i,v in pairs(players)  do
            if v.Name ~= randomp.Name or randoms.Name then
                print(v.Name .. " is innocent")
            end
        end

Why dosent this work? It should pick 1 murder, 1 sheriff and the rest innocent, and print in the output "Player 1 is sheriff" or something like that

1 answer

Log in to vote
1
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago
local sheriff   
local murderer
local innocent  = {}


local players = game.Players:GetPlayers()
murderer = players[math.random(#players)].Name
sheriff = players[math.random(#players)].Name
for i,v in pairs(players) do 
    if v.Name ~= sheriff and v.Name ~= murderer then 
        table.insert(innocent, v.Name)
    end
end

print("MURDERER: "..murderer,"SHERIFF: "..sheriff, "INNOCENTS: "..table.concat(innocent,", "))

Stop making these games, there's enough already.

1
I'm only making it to learn on how to script. I'm just trying to make as much as I can to learn so I can make my own one day NinjoOnline 1146 — 10y
0
Working, thanks :D NinjoOnline 1146 — 10y
0
Wait, 1 more thing, how can I get a script to check if a player is innocnet, so a gui can tell the player whether their innocent, murderer, sheriff, etc? NinjoOnline 1146 — 10y
0
I'd use a remote event in that script to return the role. Azarth 3141 — 10y
Ad

Answer this question