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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 07 Jan 2009 |
| Total Posts: 1547 |
|
| |
|
complexo
|
  |
| Joined: 07 Jan 2009 |
| Total Posts: 1547 |
|
| |
|
|
| 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 |
|
|
|
| 11 Jan 2017 07:36 PM |
http://wiki.roblox.com/index.php?title=API:Class/ModuleScript#Example
#code self = nil |
|
|
| Report Abuse |
|
|
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 |
|
|