text = 'announce amogus sus' -- only thing i can come up with
text = text:sub(#'announce ' + 1)
print(text) -- amogus sus
You’d like to make a structure of the command?
i.e: :announce (The whole text)?
this is good, but is there anyway to make it so when i type “announce 1 (message)”, it would only only print the “(message)” and not “1 (message)”?
local Test = table.concat(Split, ' ', 3) -- Split = local Split = Input:split(' ')
3 would be the number which tells the function that it’ll get everything after it.
I just need all the arguments past the first 2, “announce (number)”. So if I type in “announce 4 hi guys” it would print “hi guys”
Then you could do:
if string.sub(msg, 11) then -- it will show everything after the number if it's a one digit number
-- code
end
text = 'announce 1 amogus sus' -- only thing i can come up with
text = text:split(' ')
local second = text[2]
table.remove(text, 1)
table.remove(text, 2)
text = text:concat(' ')
print(text) -- amogus sus
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.
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)