Server scripts are not functioning

Hello, me and my developer friend have experienced a very odd issue.

All of our server scripts are placed in server script service and they dont fire for some weird reason. The print is not running even after debugging everything:

local WaveHelper = require(game.ReplicatedStorage.Modules.WaveHelper)

print("Started spawning")

WaveHelper:StartWave(1, 1200, {"Brawler", "Ranger"}) -- current wave, points, available enemies

If anyone has info on this topic please reply. Or if you want to know more info also please reply.
Note: this may be a roblox issue.

4 Likes

It’s because of the require. It runs the code inside the module, it’s not asynchronous. What’s inside of the module?

Hello, are you sure that in the output window, server is checked ?

1 Like

i made everything a comment inside the module apart from a print and its still not working

Like Squallysas said, make sure this is how your console looks:
image

Its the other one, all contexts

1 Like

Yep they’re all checked.

image

Hmm it seems to be something with the require because it prints anything before it.

Yes, send me the code inside the module, just send me it, it may not be what you think.

Yet its not printing whats inside the module

function WaveHelper:StartWave(Wave, MaxPoints, UnlockedEnemies)
	print("Spawining Enemy lol")
	
	if #workspace.Enemies:GetChildren() == 0 then

		local NewWave = WaveHelper.new(Wave, MaxPoints, UnlockedEnemies)

		task.defer(function()
			while NewWave.MaxPoints > 0 do
				
				print("while loop")

				local RndIndex = math.random(1, #UnlockedEnemies)
				local RndEnemy = UnlockedEnemies[RndIndex]
				local EnemyModel = game.ServerStorage.Enemies[RndEnemy]


				task.wait(.1)
				if EnemyModel.Points and NewWave.MaxPoints >= EnemyModel.Points.Value then
					NewWave.MaxPoints = NewWave.MaxPoints - EnemyModel.Points.Value
					
					print("checks passed")

					SpawnMob(EnemyModel, math.random(0,30), 5, math.random(0,30))
					task.wait(0.1)
				end
			end
		end)
		task.wait(0.1)
	end
end

Have you added something to the module and only now stopped working or it is a new one ?

Nothing it just stopped working

I removed all the code apart from the print and it still does not work

Can you post the whole module ?

local ServerStorage = game:GetService("ServerStorage")

local Modules = ServerStorage.Modules
local EnemyModules = Modules.EnemyModules

local EnemyModules = {
	
	["Brawler"] = require(EnemyModules["Brawler Enemy Module"])
}

local WaveHelper = {}
WaveHelper.__index = WaveHelper

function WaveHelper.new(Wave, MaxPoints, UnlockedEnemies)
	local self = setmetatable({}, WaveHelper) 
	self.MaxPoints = MaxPoints
	self.CurrentWave = Wave
	self.UnlockedEnemies = UnlockedEnemies
	return self
end

local function SpawnMob(Mob, X, Y, Z)
	local NewMob = Mob:Clone()
	NewMob.Parent = workspace.Enemies
	NewMob:SetPrimaryPartCFrame(CFrame.new(X,Y,Z))

	local EnemyName = NewMob.Name

	local ChosenModule = EnemyModules[EnemyName.." Enemy Module"]
	if ChosenModule == nil then warn("ENEMY MODULE IS NOT LOCATED") end
	
	ChosenModule.StartEnemyInstance(NewMob, {})
	
	return NewMob
end

function WaveHelper:StartWave(Wave, MaxPoints, UnlockedEnemies)
	print("Spawining Enemy lol")
	
	
	if #workspace.Enemies:GetChildren() == 0 then

		local NewWave = WaveHelper.new(Wave, MaxPoints, UnlockedEnemies)

		task.defer(function()
			while NewWave.MaxPoints > 0 do

				print("while loop")

				local RndIndex = math.random(1, #UnlockedEnemies)
				local RndEnemy = UnlockedEnemies[RndIndex]
				local EnemyModel = game.ServerStorage.Enemies[RndEnemy]


				task.wait(.1)
				if EnemyModel.Points and NewWave.MaxPoints >= EnemyModel.Points.Value then
					NewWave.MaxPoints = NewWave.MaxPoints - EnemyModel.Points.Value

					print("checks passed")

					SpawnMob(EnemyModel, math.random(0,30), 5, math.random(0,30))
					task.wait(0.1)
				end
			end
		end)
		task.wait(0.1)
	end
end

return WaveHelper

1 Like

Are you sure that your script can access “EnemyModules[“Brawler Enemy Module”]” in line 8 ?

If i replicate the folders and the modules you are requesting in the script it prints (in the original server script, the one who requires “WaveHelper” ), so it could be a problem with accessing EnemyModules.

This is not sure 100% since i don’t have your exacly folders and modules.

3 Likes

Yup it cant access the module. thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.