Hello Developers!
My Module Script won’t print anything. Module Script:
local module = {}
module.countDown = function(start, stop, step, secToWait)
for second = start, stop, step do
print(second)
wait(secToWait)
end
end
return module
Script:
local moduleScript = require(game:GetService("ServerStorage").ModuleScript)
moduleScript.countDown(10, 0, -1, 1)
Thanks!
2 Likes
Hello, how are you doing?
Try putting prints before and after everything, like this:
-- Script
print("before module")
moduleScript.countDown(10, 0, -1, 1)
print("after module")
-- Module script
module.countDown = function(start, stop, step, secToWait)
print("module countdown called")
for second = start, stop, step do
print(second)
wait(secToWait)
print("waited "..secToWait.." seconds")
end
print("countdown ended")
end
After you run the script, please show you’re console and the prints!
Note: Make sure the script that is calling the module script is a server script.
VikkiVuk
(NichtVikki)
March 25, 2021, 4:01pm
#3
Try changing it to this:
function module.countDown(start, stop, step, secToWait)
for second = start, stop, step do
print(second)
wait(secToWait)
end
end
Also change the “module” at the start and bottom to the script name!
They do the same thing though.
VikkiVuk
(NichtVikki)
March 25, 2021, 4:03pm
#5
Well, not exactly. Also did you read the wiki? If not here you go: ModuleScript | Roblox Creator Documentation
Nvm, I accidently placed the script inside server-storage.
It’s the same, it works fine it’s bc I placed the script inside server storage
VikkiVuk
(NichtVikki)
March 25, 2021, 4:07pm
#8
I dont understand why. Also that should’ve been the first thing you have checked.
Oh, so all this time that was the issue all along…
Glad you figured out the problem!
1 Like