Warning command doesn't show full reason

hi so I had a warning command made for me a while ago but the guy never made it so that it captures the full reason
for example if you wrote ‘:warn [player] trolling and admin abuse’ then the warning reason would only be ‘trolling’
can anyone modify it so that it works how it’s supposed to?
Here is my code:

local ChatFunctions = {
    ["warn"] = function(Words,Player)
            for _,Target in pairs(game.Players:GetPlayers()) do
                if string.find(string.lower(Target.Name),string.lower(Words[2])) then
                    if Words[3] then
                    local WarnFolder = game.Workspace:WaitForChild("WarnedPlayers")
                    local PlayerWarning = Instance.new("StringValue", WarnFolder)
                    PlayerWarning.Value = Words[3]
                    Target:WaitForChild("Warnings").Value = Target:WaitForChild("Warnings").Value + 1
                    PlayerWarning.Name = Target.Name..tostring(Target:WaitForChild("Warnings").Value)
                    end
                end
                wait()
            end
    end,
}

Instead of that you can do

words = {"test", "test2", "test3", "test4", "test5"}

print(table.concat(words, nil, 3))

output:
test3test4test5

More information: lua-users wiki: Table Library Tutorial

1 Like

I use concat for a lot of things and it never occured to me to check if it had delimiter parameters…

1 Like

Change

to:

PlayerWarning.Value = table.concat(words, nil, 3)
1 Like

It works but it removes the spaces uh…


nevermind i fixed it

You can add a separator to the concat function and you will have all your words separated by a space.

PlayerWarning.Value = table.concat(words, " ", 3)
1 Like

Yeah that’s what I did thank you anyway tho