How can I detect if a person said something in the chat (Read Description)

Hello
Im having trouble with my code, Idk how chat service works can someone please help?

How can I detect if a person said something in the chat and detect what rank are they in the group if they are in the group and they are higher than the rank 34 then make the GUI visible

2 Likes

You can use the player.Chatted event

1 Like

Then check if the player that chatted is a high role

1 Like

I tried this code:

local player = game:GetService("Players").LocalPlayer

game:GetService("Players").LocalPlayer.Chatted:Connect(function(msg)
	if msg:lower() == "/Etkinlik Sword Fight" and player.GetRankInGroup(11617668) > 32 then
		

		game.StarterGui["Etkinlik GUI"]:TweenPosition(UDim2.new(0.224, 0,0.039, 0), "Out", "Bounce", 5)
		wait(15)
		game.StarterGui["Etkinlik GUI"]:TweenPosition(UDim2.new(1, 0,0.039, 0), "In", "Bounce", 1)
		
		
	end
end)

And it did not work.

This is a ServerScriptService Script btw so normal script

LocalPlayer does not work on server only on client

1 Like

inside the “Etkinlik GUI” place a local script under it

You used msg:lower() while asking it to use capital letters. Use this:

local player = game:GetService("Players").LocalPlayer

game:GetService("Players").LocalPlayer.Chatted:Connect(function(msg)
	if msg:lower() == "/etkinlik sword fight" and player.GetRankInGroup(11617668) > 32 then
		

		game.StarterGui["Etkinlik GUI"]:TweenPosition(UDim2.new(0.224, 0,0.039, 0), "Out", "Bounce", 5)
		wait(15)
		game.StarterGui["Etkinlik GUI"]:TweenPosition(UDim2.new(1, 0,0.039, 0), "In", "Bounce", 1)
		
		
	end
end)

How can the local player work in the server?

I’m just saying that the message itself is incorrect.

Use the Players.PlayerAdded event to keep track of new players.

I tried this code and it did not work
Can someone help?

local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")

local specificWord = "/etkinlik baĹźlat sword fight"
local groupId = 11617668
local requiredRank = 34

Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		if message:lower() == specificWord and player:IsInGroup(groupId) and player:GetRankInGroup(groupId) > requiredRank then
			local etkinlikGui = StarterGui:FindFirstChild("EtkinlikGui")
			if etkinlikGui then
				local frame = etkinlikGui:FindFirstChild("Frame")
				if frame then
					frame.Visible = true
					wait(15)
					frame.Visible = false
				else
					warn("Frame not found inside EtkinlikGui")
				end
			else
				warn("EtkinlikGui not found in StarterGui")
			end
		end
	end)
end)

Thanks.

You are searching inside StarterGui. Search inside the players PlayerGui instead, like so:

local etkinlikGui = player.PlayerGui:FindFirstChild(“EtkinlikGui”)

Make sure the GUI exists on the server, too.

I tried changing the part that you told me to change and it did not work

Any errors? Try add else warn statements for every if statement.

What do you mean by

Make sure the GUI exists on the server, too.

I did not understand it.

If you created the GUI on a client, only the client would be able to see and use it. The server would not have access to it.

are you using the new chat service? or the old one

This should fix the problem:

local Players = game:GetService("Players")

local specificWord = "/etkinlik baĹźlat sword fight"
local groupId = 11617668
local requiredRank = 34

Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		if message:lower() == specificWord then
            if not player:IsInGroup(groupId) then
                return warn(`{player.Name} are not in the group.`)
            end

            if not player:GetRankInGroup(groupId) > requiredRank then
                return warn(`{player.Name} rank its too low`)
            end

			local etkinlikGui = player.PlayerGui:FindFirstChild("EtkinlikGui")
			if etkinlikGui then
				local frame = etkinlikGui:FindFirstChild("Frame")
				if frame then
					frame.Visible = true
					task.wait(15)
					frame.Visible = false
				else
					warn("Frame not found inside EtkinlikGui")
				end
			else
				warn("EtkinlikGui not found in StarterGui")
			end
		end
	end)
end)

Player.Chatted does not work on the client with the new chat. If this is in ServerScriptService than it should be fine?

I think this would be the alternative, but note that pretty much all of the easy alternatives with TextChatService don’t provide the unfiltered version of the message (unless that changed)

1 Like

Thank you it worked but I already found a better solution, however how can I make a GUI only appear on a player’s screen not everyone’s screen when the button is clicked and how do i make a gui appear on everybody’s screen if a button is pressed.