i have two scripts both spawning different npcs but they dont stop spawning
here are the two scripts: i added a print for count and rich prints 1 whereas high prints 1 both scripts are in different global scripts in serverscriptservice
local npcs = game.ReplicatedStorage.NPCs.RichCount local maxNPCs = 1 local RE = game.ReplicatedStorage.REs.UpdateGUI while wait(1) do local count = game.ReplicatedStorage.NPCcount.RichCount.Value print(count) local randomCASH = math.random(412, 750) local randomSECURITY = math.random(41, 50) local RandomX = math.random(-478, 427) local Y = 84 local RandomZ = math.random(-294, 364) if count < maxNPCs then count = count + 1 local clone = npcs:Clone() clone.RichIncomeRootPart.Position = Vector3.new(RandomX, Y, RandomZ) clone.CashValue.Value = randomCASH clone.Parent = game.Workspace.NPCs RE:FireAllClients(randomCASH,randomSECURITY, clone) end end
next script:
local npcs = game.ReplicatedStorage.NPCs.HighCount local maxNPCs = 3 local RE = game.ReplicatedStorage.REs.UpdateGUI while wait(1) do local count = game.ReplicatedStorage.NPCcount.HighCount.Value local randomCASH = math.random(250, 411) local randomSECURITY = math.random(31, 40) local RandomX = math.random(-478, 427) local Y = 84 local RandomZ = math.random(-294, 364) if count <= maxNPCs then local clone = npcs:Clone() clone.HighIncomeRootPart.Position = Vector3.new(RandomX, Y, RandomZ) clone.CashValue.Value = randomCASH clone.Parent = game.Workspace.NPCs count = count + 1 print(count) RE:FireAllClients(randomCASH,randomSECURITY, clone) end end