Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is the string.sub command not working?

Asked by 5 years ago

I am making chat commands in my game. I am able to make chat commands with one sub. Like ";kill all". It has only 1 sub which is "all", but I don't know how to make it two sub like ";cashvalue player1 100".

I have made the following script up till now. Please tell me how I can make it work. It doesn't print any thing in the output:

elseif string.sub(msg, 1, 14) == "/e ;cashvalue " then
        local target = string.lower(string.sub(msg, 15))
        local plrs = game.Players:GetPlayers()
        for i,v in pairs(plrs) do
            local tName = string.lower(v.Name)
            if string.sub(tName, 1, target:len()) == target then
                local amount = string.sub(msg, target:len() + 15)
                print("done")
        end
    end
end

Thanks!

0
You're on the right track, have you printed the result of `amount`? Goulstem 8144 — 5y
0
It doesn't print any thing. StrategicPlayZ 58 — 5y

Answer this question