Module Script Function not running... No Error or what so ever

So, i took a break of a couple of hours, and out of nowhere all my Module Functions seem not to work anymore?

This is my a small part of my script.

print("local CheckForPlayersCoreScript = require(script.Modules.CheckForPlayersCoreScript)")
local CheckForPlayersCoreScript = require(script.Modules.CheckForPlayersCoreScript)
print("CheckForPlayersCoreScript.CheckForPlayers()")
CheckForPlayersCoreScript.CheckForPlayers()
print('End:CheckForPlayersCoreScript.CheckForPlayers()')

Fun fact is, it prints
print("local CheckForPlayersCoreScript = require(script.Modules.CheckForPlayersCoreScript)") (First line), then should run the Local Require line, but this seems to fail (i guess) as the second print command is not running.

Sad thing is, the debug console shows NO error… Help?

Edit:

The targeted Module Script is inside a folder, the folder is inside the script which should do the mentioned above lines.

1 Like
local CheckForPlayersCoreScript = require(script:WaitForChild("Modules"):WaitForChild("CheckForPlayersCoreScript"))
CheckForPlayersCoreScript.CheckForPlayers()

All I can suggest is add “WaitForChild()” calls, you probably need to share the ModuleScript itself for more assistance.

1 Like

Can i see what is inside that CheckForPlayersCoreScript module?

1 Like

@shariqxD @Limited_Unique

The Module Script.
Not to mention i’m quite new to Module’s, so don’t mind the messynes.

local ShowAnnouncementBox1Remote = workspace.Remotes:WaitForChild('ShowAnnouncementBox1')
local MinimumPlayers = script.Parent.Parent.Settings.MinimumPlayers.Value
local ChangeAnnouncement1Text = workspace.Remotes:WaitForChild('ChangeAnnouncement1Text')
local GetPlayersReadyCoreScript = require(script.Parent:WaitForChild('GetPlayersReadyCoreScript'))
local PickMapCoreScript = require(script.Parent:WaitForChild('PickMapCoreScript'))


local CheckForPlayersCoreScript = {}

CheckForPlayersCoreScript.CheckForPlayers = function()
	warn('CheckForPlayersCoreScript.CheckForPlayers = function()')
	ShowAnnouncementBox1Remote:FireAllClients()
	if #workspace.InGamePlayers:GetChildren() <= MinimumPlayers then
		repeat
			ChangeAnnouncement1Text:FireAllClients("Waiting for players")
			wait(4)
			ChangeAnnouncement1Text:FireAllClients("(3+ players required)")
			wait(2)
		until #workspace.InGamePlayers:GetChildren() >= MinimumPlayers
	elseif #workspace.InGamePlayers:GetChildren() >= MinimumPlayers then
	end
	GetPlayersReadyCoreScript.GetPlayersReady()
	wait()
	PickMapCoreScript.PickMap()
end
return CheckForPlayersCoreScript

The module script’s first function line, doesn’t print either.

If you’re not getting any errors in console you can debug the function by using print() commands each line until a print seemingly fails to execute. That will indicate the point at which some exception is occurring.

I’ve placed prints already. And it seems to fail at
local CheckForPlayersCoreScript = require(script.Modules.CheckForPlayersCoreScript)

Placing :WaitForChild inside require doesn’t help either. No error, not even a error for ‘infinite wait’

No, I mean inside the function which is defined inside the ModuleScript itself, attempt to execute it in a normal script.

So, i’ve made a normal script, still in the Module Folder (as mentioned above)
This is how it looks now, take a look at the prints.

local ShowHideAFKButtonRem = game.ReplicatedStorage.ShowHideAFKButtonRemote

local ShowHideGamepassShopRem = game.Workspace.Remotes.ShowHideGamepassShopRemote

local ChangeAnnouncement1Text = workspace.Remotes:WaitForChild('ChangeAnnouncement1Text')
local CloseLoadingGui = workspace.Remotes:WaitForChild('CloseLoadingGui')
local OpenLoadingGui = workspace.Remotes:WaitForChild('OpenLoadingGui')
local GameSettingRemotes = game.ReplicatedStorage.GameSettingRemotes
local AnchorRem = GameSettingRemotes.AnchorRemote
local ChangeAmbientToClient = game.ReplicatedStorage.ChangeAmbientRemoteToClient
local DisableSeats = workspace.Remotes.DisableSeats
local StartCountDownCoreScript = require(script.Parent.StartCountDownCoreScript)
PNCPDebouunce = false
NewCurrentPlayer = nil
CurrentPlayer = nil
Found = false

function Run()
warn('RUNNING')
if PNCPDebouunce == true then return end
PNCPDebouunce = true
Found = false
repeat
NewCurrentPlayer = game.Workspace.PlayersInMatch:GetChildren()[math.random(1,#workspace.PlayersInMatch:GetChildren())]
CurrentPlayer = game.Players:WaitForChild(NewCurrentPlayer.Name)
print('NewCurrentPlayer = ',CurrentPlayer,'.')
Found = true
PNCPDebouunce = false
return CurrentPlayer
until Found == true
PNCPDebouunce = false
end
wait(15)
warn('Going to run')
Run()

I’m not kidding, but the warn’s are not printing…
Now, by removing “local StartCountDownCoreScript = require(script.Parent.StartCountDownCoreScript)”

It seems to run, finally with a error…

  22:40:49.780  Going to run  -  Server - TestScript:33
  22:40:49.780  RUNNING  -  Server - TestScript:17
  22:40:49.780  ServerScriptService.MainScriptRewroteV4.Modules.TestScript:22: invalid argument #2 to 'random' (interval is empty)  -  Server - TestScript:22
  22:40:49.780  Stack Begin  -  Studio
  22:40:49.780  Script 'ServerScriptService.MainScriptRewroteV4.Modules.TestScript', Line 22 - function Run  -  Studio - TestScript:22
  22:40:49.780  Script 'ServerScriptService.MainScriptRewroteV4.Modules.TestScript', Line 34  -  Studio - TestScript:34
  22:40:49.780  Stack End  -  Studio
1 Like

^^^ This error usually happens when the second argument is lower than the first, or if there is no input.

Try this:

local ShowHideAFKButtonRem = game.ReplicatedStorage.ShowHideAFKButtonRemote

local ShowHideGamepassShopRem = game.Workspace.Remotes.ShowHideGamepassShopRemote

local ChangeAnnouncement1Text = workspace.Remotes:WaitForChild('ChangeAnnouncement1Text')
local CloseLoadingGui = workspace.Remotes:WaitForChild('CloseLoadingGui')
local OpenLoadingGui = workspace.Remotes:WaitForChild('OpenLoadingGui')
local GameSettingRemotes = game.ReplicatedStorage.GameSettingRemotes
local AnchorRem = GameSettingRemotes.AnchorRemote
local ChangeAmbientToClient = game.ReplicatedStorage.ChangeAmbientRemoteToClient
local DisableSeats = workspace.Remotes.DisableSeats
local StartCountDownCoreScript = require(script.Parent.StartCountDownCoreScript)
local PNCPDebouunce = false
local NewCurrentPlayer = nil
local CurrentPlayer = nil
local Found = false

function Run()
	warn('RUNNING')
	if PNCPDebouunce == true then return end
	PNCPDebouunce = true
	Found = false
	if #workspace.PlayersInMatch:GetChildren() >= 1 then
		repeat
			NewCurrentPlayer = game.Workspace.PlayersInMatch:GetChildren()[math.random(1,#workspace.PlayersInMatch:GetChildren())]
			CurrentPlayer = game.Players:FindFirstChild(NewCurrentPlayer.Name)
			print('NewCurrentPlayer = ',CurrentPlayer,'.')
			if CurrentPlayer then
				Found = true
			end
		until Found == true or #workspace.PlayersInMatch:GetChildren() == 0
		PNCPDebouunce = false
	else
		PNCPDebouunce = false
	end	
end
wait(15)
warn('Going to run')
Run()