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

make sure you get a murderer and then chose detective but make sure detective isn't murderer?

Asked by 6 years ago

So I want to randomize what roles people get on my server, I want one person to become detective, one person to become a doctor, and the other to become a murderer, how do I make sure that one of those roles don't get assigned to the same person again?

0
"again"-- As in while selecting the roles in the same round or preventing them from receiving the same role as they were in a previous round, as theCJarmy7 is describing? c0des 207 — 6y
0
Same round, Though theCJarmy7's suggestion was somewhat helpful but not entirely, I don't want the murderer to be chosen as a doctor or detective as well in the same round. aoaoaoaoa00 4 — 6y

1 answer

Log in to vote
0
Answered by
theCJarmy7 1293 Moderation Voter
6 years ago

There are many ways to do this, you could make a table of all the detectives, you could save a value inside the player to check what they were last round, you could have a simple if statement etc. What I would do involves creating a value inside the player to check what they were last round

game.Players.PlayerAdded:connect(function(player)
    --whenever a player joins, insert a value into them
    local WasLast = Instance.new("StringValue",player)
    WasLast.Name = "WasLast"
    WasLast.Value = "whatever"
end)

With this value in place, you can check if the player was a certain something last round.

local function checkWasLast(player)
    return player:FindFirstChild("WasLast").Vaue
--this function isn't really that useful, but I thought I'd put it in anyway
end

And there you have it, simply set the value of the, ahem, value to whatever they were last, and make sure they don't become that again.

Ad

Answer this question