When player chat, UI not enabled true

I am trying to script when a player above the rank in my group says “Host” a UI will be enabled true, but It’s not working. Can anyone see the problem?

local GroupId = 7446763 
local MinimumRank = 7 
local Command = game.StarterGui.Announce

game.Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		if Player:GetRankInGroup(GroupId) >= MinimumRank then
			if Message == "Host" then
				Command.Enabled = true
			elseif Message == "Close" then
				Command.Enabled = false
			end
			end
		end

you’re going into the startergui and not the playergui.
here is what you should have done:

local GroupId = 7446763 
local MinimumRank = 7 

game.Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		if Player:GetRankInGroup(GroupId) >= MinimumRank then
			local Command = Player.PlayerGui.Announce
			if Message == "Host" then
				Command.Enabled = true
			elseif Message == "Close" then
				Command.Enabled = false
			end
		end
	end)
end)

(I also fixed a couple mistakes you had in your script like missing a few ends, etc.)
Also, if you were trying to make it so it was visible for everyone on the server, please reply with that so I can revise the script.

2 Likes

Thank you, it worked! I dont know how to script