Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make murder, sheriff and innocent?

		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

✓ Accepted answer
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.

4 comments

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

0

Working, thanks :D

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?

0

I'd use a remote event in that script to return the role.

This discussion is preserved as it was. New answers, comments, and votes are closed.