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

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

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

2 comments

0

its not a very complicated question, I dont think

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.

2 answers

✓ Accepted answer

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.

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()

2 comments

0

Thanks :D

0

Thanks :D

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