I need help with Chat Triggers

-- UserIds of players who have access to chat commands
local Admins = {
	112896842,
	155350575
}

local Players = game:GetService'Players'

local function IsAdmin(Player)
	return table.find(Admins, Player.UserId)
end

local function OnChatted(Player, Message)
	if not IsAdmin(Player) then return end
	local Args = string.split(Message, " ") -- Split the message into a table of all words
	local Command = table.remove(Args, 1) -- Get the first word of the message and remove it from the words table
	if Command == "!host" then
		print'Host'
		local HostGui = game:GetService'ServerStorage'.HostGui:Clone() -- assuming the billboard gui is named "HostGui"
		HostGui.Parent = Player.Character.Head
		HostGui.Adornee = Player.Character.Head
	end
end

local function OnPlayerAdded(Player)
	Player.Chatted:Connect(function(Message)
		OnChatted(Player, Message)
	end)
end

Players.PlayerAdded:Connect(OnPlayerAdded)
2 Likes

Is this in the right order?

image

1 Like

Put the script in a server script inside ServerScriptService

1 Like

Alright done what is the next step?

1 Like

Chat “!host” and it should put the host gui inside of your character

1 Like

Seems not to be working.

1 Like

You need to put a textlabel inside of the billboard gui Lol, and then change the Text property of it to like “Host” or something

1 Like

Oh yeah I am so sorry lol let me do that real quick lol.

1 Like

You can use Player.Chatted but i prefer ChatService because you can do alot of things with it that you can’t do with Player.Chatted.

1 Like

Alright once I go to the link what would I do after?

1 Like

Just read what it tells you to do.

1 Like

Yeah I just did that and it still did not work when I said “!host” in chat.

1 Like

Name it “HostGui” not “HostGUI”

2 Likes

Done, Still nothing sadly. Ive done every step and still do not know what is wrong with it lol.

1 Like

Can you show the hierarchy of the script and the billboard gui

1 Like

Is your userId in the admin list?

1 Like

Yes it is hell_ish added it to the coding.

1 Like

image

1 Like

Its HostGui and you named the billboard HostGUi

1 Like

Oh my mistake. Thank you.

1 Like