Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

2 comments

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

0

thanks bro

This discussion is preserved as it was. New answers, comments, and votes are closed.