I have a script that clones random zombie models in a random position and into the workspace.
--variables topLeft = Vector3.new(-85.3, 0.5, -30.9) --Top left corner of the 2d region bottomRight = Vector3.new(-43.2, 0.5, 6.9) --Bottom right corner of the 2d region az = game.ReplicatedStorage.zombiemodels.A bz = game.ReplicatedStorage.zombiemodels.B cz = game.ReplicatedStorage.zombiemodels.C dz = game.ReplicatedStorage.zombiemodels.D ez = game.ReplicatedStorage.zombiemodels.E fz = game.ReplicatedStorage.zombiemodels.F gz = game.ReplicatedStorage.zombiemodels.G singletonRandom = Random.new(tick()) --Function for the random number function GetRandom(Min,Max) return singletonRandom:NextNumber(Min,Max) end --Making the cloning items PlayingFieldHeight = 15 while true do local phrases = { az, bz, cz, dz, ez, fz, gz } print ( phrases[ math.random( #phrases ) ] ) model = (phrases[math.random(#phrases)]):clone() model.Parent = game.Workspace model.PrimaryPart = model.HumanoidRootPart model:SetPrimaryPartCFrame(CFrame.new(GetRandom(topLeft.X,bottomRight.X),PlayingFieldHeight,GetRandom(topLeft.Z, bottomRight.Z))) wait(2) end
I am very very new to scripting so please cut me some slack here, but I need to find out how I can count how many models are in the workspace with the corresponding names "A, B, C, D, E, F, G" and then disable the script when the number has reached the threshold I give it. Any help on how I can do this? I have no idea.
I don't understand your script but I'll just do what the question asked
for i,v in pairs(workspace:GetChildren()) do if v:IsA("Model") then local number = #v if number >= 5 then -- If there are more than 5 models script.Disabled = true end end end
local s = --Script here while true do wait() if tonumber[game.Workspace:GetChildren()] >= 20 then s.Disabled = true end end
That is what I would do.