Hide chat for 1 specific player

I want to hide the chat for one player.

I have this spell which silences the target, so I want to hide the chat for that person.

I’m aware of setting the core gui chat to false but im not sure if this can be done in a local script.

It can ONLY be done in a local script. So yeah, that’s the way to do it: game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)

1 Like

I want to hide this for one player though. Changing the whole startergui would do it for everyone, right?

Would I just change it to the target’s player gui instead of starter gui?

Use a remote event, and fire that remote to a specific player you want to hide the chat from.

No, not if you do it for only one player, if you place that local script in starter player and have it run immediately then it will, otherwise, not.

So…

To hide it from 1 player do i just replace startergui with that player’s PlayerGui and hide chat that way

eg:

game:GetService("Players").AdSomnum.PlayerGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)

You can’t SetCoreGuiEnabled on a players PlayerGui

so how do i hide it from one player then

You can try to fire a remote from the server to that specific client [using ‘FireClient’] and then, on the client, disable the chat for him using the method mentioned above.

so

event:FireClient(targetplayer, "HideChat")

and then

event.OnClientEvent:Connect(function(targetplayer, hidechat)
if hidechat then
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)

Alright, I just made a test to confirm it works:
(BTW Remotes folder in ReplicatedStorage with a HideChat remote event.)
Local script (StarterPlayerScripts):

local Remotes = game.ReplicatedStorage.Remotes
local HideChat = Remotes.HideChat
local Player = game.Players.LocalPlayer

HideChat.OnClientEvent:Connect(function()
	print(Player.Name.." has fired HideChat")
	game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
end)

Then in a server script just call FireClient(Player) on the Player you want to hide it for.

do you think my script would work as well?

Remove targetplayer from that line, you don’t specify the player parameter there with OnClientEvent but you still need to pass it in

1 Like

where do i put this script? StarterPlayerScripts?

Yes. That’ll work just fine. .