Get all arguments past arg[2]

but it varies, the message could be “announce 1 (message)” and “announce 2 (message)”, and so forth.

Yes, but the third argument in that case would still be the message itself.
announce = 1
number = 2
message = 3

Yes, but for example when I do “announce 4 Please evacuate the building!”, it would only print “Please” since that is the 3rd argument. I need all the words after the 2nd arg.

Have you even tried my code?
Do that before replying please.

ServerScriptService.TabletManager:32: attempt to call a nil value

errors on "text = text:concat(’ ') "

Won’t that only show the 3rd word?

No, everything after it.
If you test it you’ll see.

Do table.concat(text, ’ ').

game.Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		local Command, Message = string.match(Message, "(%S+)%s(%S+)")
		
		if Command == "announce" then
			print(Message)
		end
	end)
end)

He isn’t using a chatted function for it though

It’s the same thing, he will have to use string.match() and format it.

Alright guys, thanks for all the replies, @Xacima’s code worked. Thanks!

2 Likes

https://gyazo.com/f8525569fe358172ac6140de08ed09a5

local TextBox = script.Parent

TextBox.FocusLost:Connect(function()
	local Text = TextBox.Text
	local Command, Message = string.match(Text, "(%S+)%s(%S+)")
	
	if Command == "announce" then
		print(Message)
	end
end)