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

How can this code not work!?

Asked by 9 years ago

Hello, I tried to make a method function for workspace to make a part in and put in "()" its name. What is wrong? It asks me in line 6 for an object literally for no reason I can think of.

** Workspace.Script:6: bad argument #3 to 'Workspace' (Object expected, got table)**

game.Workspace = {
    MakePart = function(n)
        local a = Instance.new("Part", game.Workspace)
        a.Name = n
    end
}
game.Workspace:MakePart("Explantation, anyone?")

1 answer

Log in to vote
0
Answered by 9 years ago

Try this:

function MakePart(n)
local a = Instance.new("Part", workspace)
a.Name = n
end
MakePart("This Should Work!")
0
No, I mean, it should a function of workspace, like game.Workspace:FindFirstChild() MagicGivePen 0 — 9y
Ad

Answer this question