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

How would I call a module script function inside of a module script ?

Asked by
Nootian 184
4 years ago
Edited 4 years ago

For example, I want to do this:

local module = {}
    function module.destroyPart()
        workspace:FindFirstChild("ClonedPart"):Destroy()
        print("Destroyed :)")
    end
    function createpart()
        Cloned = workspace.part:Clone()
        Cloned.Name = "ClonedPart"
        wait(5)

        --How would I do this?: (I just guessed on how to do it below)
            module.destroyPart()
    end


return module
0
its not a very complicated question, I dont think Nootian 184 — 4y
0
You can't do that sir, you can only call module scripts from scripts or local scripts; the same rule goes with remote events and functions, you can only access them from a local script. maxpax2009 340 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

That would work. However you would need to call createpart from a script, so instead of making it a normal function, make it a module function by simply making it module.createpart.

Ad
Log in to vote
1
Answered by
Ciyob86 25
4 years ago
Edited 4 years ago

Just require the module script in the module script and start the function. Make sure the module script with the function and the module script calling the function have different name. replace "name" with full name of module script with function and replace function with the function to be called.

require(name)
name.function()
0
Thanks :D Nootian 184 — 4y
0
Thanks :D Nootian 184 — 4y

Answer this question