How to find a players name with a type of chat

I want to make it so where if someone says a players name with "RUN NAME " before it it will print something for now.

For Example if someone says “RUN NAME coolboy24” then it will just simply print something for now

Player.Chatted:Connect(function(ChatMessage)
	if Active == false then return end
	if ChatMessage then
		if ChatMessage == "RUN NAME "..game.Players:FindFirstChild(ChatMessage) then
			print("Worked")
		end
	end
end)```

my code so far, obviously with the whole ChatMessage "RUN NAME coolkid24" is not a player
1 Like

use string.split() to do this.

if ChatMessage == "RUN NAME "..game.Players:FindFirstChild(string.split(ChatMessage, " ")[3]) then

Also, I recommend using checks to prevent errors, but this should work fine.

Player.Chatted:Connect(function(ChatMessage)
	if Active == false then return end
	if ChatMessage then
		if ChatMessage == "RUN NAME "..game.Players:FindFirstChild(string.split(ChatMessage, " ")[3]) then
			print("Worked")
		end
	end
end)

I tried this but it came up with this error
16:49:53.712 Players.d_rewops.PlayerGui.ScreenGui.Client Radio:76: attempt to concatenate string with Instance - Client - Client Radio:76

add a .Name after the FindFirstChild to fix this.

Thank you so much!! how can I make it so where you dont need the right capitalization?

Nevermind, don’t want to bother you anymore.

You can use the :lower function.
More information: https://gyazo.com/2db65039a7ec202f2b9253372c039b14
Example:

if (String:lower() == 'abcdef')
then
   print(String)
end