Line that requires a module makes script stop/yield?

Hey, so I’m making a fps and everything’s coded and setted up, and the first time playing, nothing worked. I immediately slapped some prints to identify the line, as there were no errors, and looks like the line that requires my fps module is stopping/yielding the script:

local uis = game:GetService("UserInputService")
local rs = game.ReplicatedStorage
local runService = game:GetService("RunService")
print("print 0") -- prints
local modules = rs:WaitForChild("modules")
local guns = rs:WaitForChild("guns")
local gunRemotes = rs:WaitForChild("gunRemotes")
print("print 1") -- prints
local fpsModule = require(modules:WaitForChild("fpsModule")) -- 😎
print("print 2") -- doesn't print
local cam = workspace.CurrentCamera

local player = game.Players.LocalPlayer

local newGuns = {}

There are no errors, such as “module experienced an error while loading”, “infinite yield on line …”, and I’d like to know what is causing it to stop/yield, and hopefully a fix?

Try some print debugging inside fpsModule as well to see if something inside there is holding things up.

1 Like

Are you also sure you spelled the name in the explorer correctly?

Yup, even if I didn’t, it would give a “infinite yield possible” error.

Thanks for the suggestion, will do that.

your fpsModule has something that yields/prevents returning in it, such as an Event:Wait(), repeat until, while x do, or something of the like.
Check that everything runs quickly, and if it doesn’t wrap it in a coroutine:

coroutine.wrap(function()
    -- code that doesn't run quickly
end)()
1 Like

I only had a repeat until in my gun fire function, wrapped that into a coroutine but still doesn’t print “print 2”.

    coroutine.wrap(function()
		
		repeat
		
			self.canFire = false
			
			fire()
			
			self.canFire = true
		
		until self.ammo[self.gunName] <= 0 or not self.firing
		
	end)()