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

tostring not working? [Solved]

Asked by 8 years ago

I have a problem with tostring. I keep getting the error: bad argument #2 to 'match' (string expected, got Object). My code is:

local part = script.Parent
local model = part.Parent
local running = false
local wsChildren = workspace:GetChildren()

function onTouch(hit)
    local h = hit.Parent:findFirstChild("Humanoid")
    local hString = tostring(h.Parent)
    if h ~= nil and not running then
        running = true
        for x = 1, #wsChildren do
            if tostring(x):match(hString) ~= nil then --error occurs here
                break
            end
        end
    end
end

I have also tried string.match but the same error happens.

0
use .Name theCJarmy7 1293 — 8y
0
h.Parent.Name theCJarmy7 1293 — 8y
0
That worked. Thanks! Vill1234 15 — 8y

Answer this question