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

Can you do string manipulation on a table?

Asked by 6 years ago

I'm just trying to work out string.reverse, but it says attempted to index "string, a nil value"

This is what I have

local encryptThese = {}

function basicEncryption()
    for i,v in pairs(game.Workspace:GetChildren()) do
        if v.Parent == game.workspace then
            print(v)
            table.insert(encryptThese, v)
            encryptThese.string.reverse()
        end
    end
end

basicEncryption()
0
You can also call it with `:` For example `local a = "ABCD" print(a:reverse())` prints `DCBA`. XAXA 1569 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

string.reverse is used like this:

string.reverse("test") --> tset
0
Yea, I figured that out eventually. Thanks though :) KennySfromTitan 106 — 6y
0
You're welcome. lol User#18043 95 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

No, but you can set them like this.

local atable = {'Hello', 'from', 'hiimgoodpack!'}
for i = 1, #atable do
    atable[i] = string.reverse(atable[i])
end

This will turn the table keys from Hello from hiimgoodpack! to olleH morf !kcapdoogmiih I hope this helps you in the future!

Answer this question