generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How do I run a function in another script with parameters?

Previous Thread :: Next Thread 
complexo is not online. complexo
Joined: 07 Jan 2009
Total Posts: 1547
11 Jan 2017 04:56 PM
I've tried ModuleScript, but even though I'm following convention:

local module = {}

function module.explode(position, radius, pressure)...

Other scripts trying to run the function via script.damageBlock.explode(...) (the ModuleScript is called damageBlock, and is a child of the script) just complain "explode is not a valid member of ModuleScript".
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
11 Jan 2017 04:58 PM
This works for me: --script in serverscript service local mod = require(script.ModuleScript) mod.explode("beep beep beeeeep") --module script in script local module = {} module.explode = ############# ########## "boom") end return module
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
11 Jan 2017 05:00 PM
Ok I really hate the roblox hashing system



--script in serverscript service

local mod = require(script.ModuleScript)
mod.explode("beep beep beeeeep")

--module script in script

local module = {}

module.explode = function(string)
print(string, "boom")
end

return module
Report Abuse
complexo is not online. complexo
Joined: 07 Jan 2009
Total Posts: 1547
11 Jan 2017 05:18 PM
I forgot the "return module" part and added it, but it still doesn't work.
Also, the script is part of a weapon rather than the ServerScriptService, and the ModuleScript contains regular functions as well as module functions; could either of those be the problem?
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
11 Jan 2017 05:22 PM
I don't think any of those could be the problem.

Are you sure you required the module?

Are there any error messages in the output?
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
11 Jan 2017 05:24 PM
As long as the weapon is in the workspace.
Report Abuse
complexo is not online. complexo
Joined: 07 Jan 2009
Total Posts: 1547
11 Jan 2017 05:29 PM
I've simply taken the default rocket launcher, made the damageBlock ModuleScript a child of the Rocket script (which in turn is a child of a localscript), and in the Rocket script I've added "script.damageBlock.explode(..., ..., ...)" just after the explosion is created.

The rocket launcher is part of the starterpack, and is used by the player as normal.
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
11 Jan 2017 05:31 PM
Did you require the module?

http://wiki.roblox.com/index.php?title=Global_namespace/Functions_specific_to_ROBLOX#require
Report Abuse
complexo is not online. complexo
Joined: 07 Jan 2009
Total Posts: 1547
11 Jan 2017 05:40 PM
No, how should I implement it?

I tried the obvious of changing
script.damageBlock.explode(..., ..., ...)
to
require(script.damageBlock.explode(..., ..., ...))

but that didn't work.
Report Abuse
complexo is not online. complexo
Joined: 07 Jan 2009
Total Posts: 1547
11 Jan 2017 06:49 PM
Bump
Report Abuse
complexo is not online. complexo
Joined: 07 Jan 2009
Total Posts: 1547
11 Jan 2017 07:34 PM
Bump
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
11 Jan 2017 07:36 PM
on the script you are trying to use the module

local module = require(MODULE SCRIPT)

module.explode (args)

Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
11 Jan 2017 07:36 PM
http://wiki.roblox.com/index.php?title=API:Class/ModuleScript#Example


#code self = nil
Report Abuse
complexo is not online. complexo
Joined: 07 Jan 2009
Total Posts: 1547
11 Jan 2017 08:30 PM
Alright, making the require only include the modulescript worked.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image