Why isn't this running?

Whenever I run the game in studio, the RunService:IsRunning(), or at least the conditional statement doesn’t seem to be running at all because the lines of code after it do not run, this code is at the end of a module script, what am I doing wrong?

function spawnStudioCollectables()
	print("ok")
	for i, posPart in pairs(testCollectableLocations:GetChildren()) do
		dropBox:createCollectable(collectableList[math.random(1, #collectableList)], posPart.Position)
		print("yo")
	end
	print("done")
end

print("hi")
if game:GetService("RunService"):IsRunning() then
	print("yes")
	spawnStudioCollectables()
	print("done")
end

Are you requiring the ModuleScript in another Script? ModuleScripts don’t run by design unless required

Yeah did require it in another script, although the snippet of code is inside of the module and isn’t used by any scripts in my game.

It could be that the conditional statement returns false. As in the conditional statement runs before “RunService:IsRunning()” can return true.

1 Like