Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Changing the parent of a with the path string?

So I have the path string, please note the string, how would I change it's parent? When I mean the path's string:

local x = game.Workspace.Part:GetFullName()
-- returns: Workspace.Part

I've already tried methods such as:

game:FindFirstChild(x)
-- Although this returns nil.

3 answers

✓ Accepted answer

As TheLuaUser said, GetFullName is mainly used for debugging purposes only.

Although, there is a way you could potentially get the object referred to by a string returned by the GetFullName. Using string manipulation, you could do something like this:

function findObjectWithAbsolutePath(path)
    local obj = game
    
    for match in path:gmatch("%w+") do
        local obj = obj:FindFirstChild(match)
        
        if not obj then
            return nil
        end
    end
    
    return obj
end


findObjectWithAbsolutePath(object:GetFullName())

GetFullName is for print purposes only.

You should do local x = game.Workspace.Part instead.

This discussion is preserved as it was. New answers, comments, and votes are closed.