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

How would I turn off a players chat after they die?

Asked by
Relatch 550 Moderation Voter
9 years ago

I'm making a mad murderer game, and to prevent players from giving out the killers name, I want to turn their chat after they die. After the round is over I want to turn their chat back on. If you can help me out, thank you very much.

1 answer

Log in to vote
1
Answered by 9 years ago

I would suggest that you put all players that are in the round in a table. After that I would iterate over the table and remove any players that have died. You could then run this bit of code when the player spawns in order to set their chat visible or not. You will have to run this in a LocalScript but you would have to receive the table data from a ServerScript via a ModuleScript or some other form.

game.Players.LocalPlayer:SetCoreGuiEnabled("Chat", false)

for i, v in pairs (PLAYERSTABLE:GetChildren()) do
    if v.Name == game.Players.LocalPlayer.Name then
        game.Players.LocalPlayer:SetCoreGuiEnabled("Chat", true)
    end
    wait()
end

Of course you could also run the loop above in the ServerScript that has the table in it. You would just have to iterate over the table whenever a new character spawned into the game.

Ad

Answer this question