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

How do I correctly use module scripts with functions in server scripts?

Asked by 4 years ago

So I attempted to use a function in a module script and then use it In server scripts but its not working obviously because I don't know how to use it can anyone tell me the proper way to use it here is my script

Module script

local module = {}

function Destroy(part)
    part:Destroy()
end



return module

Server Script


Module = require(game.ReplicatedStorage.ModuleScript) Module:Destroy(game.Workspace.Baseplate)

1 answer

Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
4 years ago
Edited 4 years ago

In function you put

function Destroy(part)

end

When it should be

function module.Destroy(part)

end

Oh and there is another issue.

You're destroying the Module script instead of running the destroy function.

ModuleScript.Destroy(workspace.BasePlate)
0
To add some information: The format given is needed because it "attached" function Destroy to the module table. Because you return the table for other scripts to use, not attaching the function means nothing but the module has access to said function alphawolvess 1784 — 4y
0
thanks bro Mr_Unlucky 1085 — 4y
Ad

Answer this question