The only thing I can think of is “troubleshooting” your else statements, this can be achieved with the following:
local Lighting = game:GetService("Lighting")
local Entities = game:GetService("ReplicatedStorage"):WaitForChild("Entities")
local EntitiesModule = require(script.Entities)
local EntityTable = {
Table = {
Entities.Zombie;
};
Count = 100;
Parent = workspace.Entities;
}
local NeutralEntityTable = {
Table = {
Entities.Pig;
};
Count = 7;
Parent = workspace.NeutralEntities;
}
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
if Lighting.ClockTime >= 18.6 or Lighting.ClockTime <= 6 then
EntitiesModule:AddEntities(EntityTable)
else
print("A")
EntitiesModule:RemoveEntities()
end
if Lighting.ClockTime >= 6.3 or Lighting.ClockTime <= 18.6 then
EntitiesModule:AddEntities(NeutralEntityTable)
else
print("B")
EntitiesModule:RemoveEntities()
end
end)
This is probably not the most efficient way to troubleshoot however it can work. Additionally it would help if you provided the module script for reference.
function module:AddEntities(Entities)
if EntitiesSpawn == false then
EntitiesSpawn = true
if typeof(Entities) ~= "table" then
error("Provide a table please!")
return
end
for i = 1, Entities.Count do
local Randomize : Model = Entities.Table[math.random(1, #Entities.Table)]:Clone()
Randomize.Parent = Entities.Parent
Randomize:PivotTo(CFrame.new(
math.random(-workspace.Terrain.Size.X / 1.5, workspace.Terrain.Size.X /1.5),
workspace.Terrain.Size.Y + 150,
math.random(-workspace.Terrain.Size.Z / 1.5, workspace.Terrain.Size.Z / 1.5)
)
)
task.wait()
end
end
end
function module:RemoveEntities()
workspace.Entities:ClearAllChildren()
workspace.NeutralEntities:ClearAllChildren()
EntitiesSpawn = false
end