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

'Create' function usage?

Asked by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago
local Create = assert(LoadLibrary("RbxUtility")).Create

local projectiles = {
    icebolt = {
        Name = "Icebolt",
        Parent = Workspace,
        BrickColor = BrickColor.new("Bright blue"),
        Reflectance = .5,
        Transparency = .2,
        Anchored = true,
        FormFactor = Enum.FormFactor.Custom,
        Size = Vector3.new(1, .4, .4),
    };
}

function fire(target, projectile)
    local proj = Create("Part")(projectiles[projectile])
end

return{
    Fire = fire
}

I'm trying to use the Create function of the RbxUtility to create the parts for this projectile launcher ModuleScript, but this doesn't appear to be working.

The fire function here is called once:

local proj = require(script.Parent.ProjectileScript)
proj:Fire(nil, "icebolt")

But the icebolt isn't being created from the 'icebolt' table in the ModuleScript, it is only creating a new Part with no properties changed from default.

1
Wow, your question is really thorough ._. Legojoker 345 — 9y
1
This is above my head. Congrats on being able to understand it. Perci1 4988 — 9y
1
I can understand it a little with the help of the wiki link he gave xD but yeah unfortunately I doubt I'll be able to help either D: Legojoker 345 — 9y
1
OH! maybe if you made icebolt a string value in the table it would work? Like ["icebolt"] = {properties for the icebolt} I think that should fix it. Legojoker 345 — 9y
View all comments (3 more)
1
Hmm , I think I know the problem. HexC3D 830 — 9y
0
Please share, Hex. @Lego; the way I wrote it is just syntactic sugar for the way you wrote it. They are interpretted into the exact same bytecode. adark 5487 — 9y
1
Oh, sorry then, I never knew that! Well thanks for the lesson xD Legojoker 345 — 9y

Answer this question