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

Why do I get a table instead of an Object?

Asked by 4 years ago
Edited 4 years ago

Hello scripters and helpers,

It's the first time I use ModuleScripts and I've tried to make a function that let's me generate a Frame on a easy way. Here is my first Code in my ModuleScript:

local page = {}

function page.new(parent)
    local Object = Instance.new("Frame")--Problem
    Object.Parent = parent
    return Object
end


return page

My second script is also a ModuleScript. Rough pieces from the script:

local new = Instance.new
local pgui = Player.PlayerGui
local screen = new("ScreenGui", pgui)
local mainpage = page.new(screen)

At the last Line it gives me an error and at the first ModuleScript where I marked: bad argument #3 to 'Parent' (Object expected, got table)

I don't know, what I do wrong.

With best regards,

Ferdinand

Answer this question