I'm trying to make an admin commands script, but it does not work with the concat.
thanks!
local function Split(String) local Table = {} for I = 1, #String do table.insert(Table, string.sub(String, I, I)) end return Table end local player = game.Players.LocalPlayer player.Chatted:Connect(function(msg) if msg:find("!print") then local memes = msg print(memes) local memes = Split(msg) table.remove(memes, 1) table.remove(memes, 1) table.remove(memes, 1) table.remove(memes, 1) table.remove(memes, 1) table.remove(memes, 1) table.concat(memes) print(memes[1]) end end)
it prints out "h" if i do "!print hi". thanks for any help!!
You're splitting the command into individual chars.
A better way would be to do something like string.match(YOUR_STRING, "%a+")
(for letters only) or you could "%s+"
to get whitespace and split it that way.
A list of all the string patterns can be found here: https://developer.roblox.com/en-us/articles/string-patterns-reference
EDIT: "%w+"
is for alphanumeric characters, perfect for commands.