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: Somebody help me with this ModuleScript, it's very simple.

Previous Thread :: Next Thread 
invrt is not online. invrt
Joined: 02 Dec 2015
Total Posts: 12
17 Jun 2017 07:36 PM
Alright, so I have trouble with Module Scripts so I decided to make a VERY easy one.
--------------------------------------------

TestScript (located in Workspace):

myModule = require(game:GetService("ServerScriptService").ModuleTestScript)
myModule.printThis("The Room Where It Happens")

--------------------------------------------

ModuleTestScript (located in ServerScriptService):

local module = {}

function printThing(text)
print(text)
end

return module

--------------------------------------------

Very simple, right? Now, somebody please tell me why I get this error and how I can fix it: Workspace.TestScript:2: attempt to call field 'printThis' (a nil value)



Report Abuse
veryveryveryhidden is online. veryveryveryhidden
Joined: 16 Dec 2012
Total Posts: 486
17 Jun 2017 07:37 PM
Hello, since you are returning the "module" table.. the function must be in the table.


local module = {}

function module.printThing(text)
print(text)
end

return module
Report Abuse
good_evening is online. good_evening
Joined: 30 May 2010
Total Posts: 791
17 Jun 2017 07:38 PM
printThis doesn't exist in your module. It's printThing.
Report Abuse
veryveryveryhidden is online. veryveryveryhidden
Joined: 16 Dec 2012
Total Posts: 486
17 Jun 2017 07:38 PM
Oh. That too.
Report Abuse
invrt is not online. invrt
Joined: 02 Dec 2015
Total Posts: 12
17 Jun 2017 07:40 PM
Ah, thanks! I understand the scripts better now, also thanks for the quick reply.


Report Abuse
invrt is not online. invrt
Joined: 02 Dec 2015
Total Posts: 12
17 Jun 2017 07:55 PM
Okay, sorry but I have another issue. Here's the script.
-----------------------------------------
ModuleScript:

local module = {}

function module.onTouch(hit)
print(hit.Name)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local walkSpeed = humanoid.WalkSpeed
local speedBoost = 20
local regularSpeed = 16
for i = regularSpeed, speedBoost + 1 do
walkSpeed = i
wait()
end
end

return module
-----------------------------------------
Script:

local scriptFunctions = require(game:GetService('ServerScriptService').ModuleScript)

script.Parent.Touched:connect(scriptFunctions.onTouch())
-----------------------------------------
ServerScriptService.ModuleScript:4: attempt to index local 'hit' (a nil value)

I'm trying to make a little Speed Run function via the Module Script so that I can reuse it at ease.



Report Abuse
veryveryveryhidden is online. veryveryveryhidden
Joined: 16 Dec 2012
Total Posts: 486
17 Jun 2017 07:57 PM
script.Parent.Touched:connect(scriptFunctions.onTouch)
Report Abuse
invrt is not online. invrt
Joined: 02 Dec 2015
Total Posts: 12
17 Jun 2017 08:08 PM
Thanks, once again.


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