local infamount = script.Parent.Parent.NpcFolder.Values.InfantryCount.Value

for i = 1, infamount do

wait(1)

if infamount <= 0 then

print("broke loop")

break

end

if infamount >= 1 then

print("spawning troop")

local point = script.Parent.Parent.Parent.DropSpawn

local offset = Vector3.new(0,-4,0)

local copy = game.ServerStorage.Npcs.Infantry:Clone()

copy.Parent = game.Workspace

copy:SetPrimaryPartCFrame(point.CFrame + offset)

copy.MasterFolder.EnableAll.Disabled = false

infamount.Value = infamount.Value - 1

end

end

Im trying to get this loop to spawn some npcs. infamount.Value is the number of times the for loop should spawn the npcs. but instead of throwing an error it just doesnt even run past the first line. I think but im not sure I might have the for loop set up wrong but correct me if Im wrong.

4 comments

0

the infamount variable is an integer , not an object, meaning it doesnt have a value property

0

infamount is supposed to be a number, all it does is represent the number of times the npc (which is copied from serverstorage) spawns.

0

edit: welp, found out that the script itself isnt being enabled due to another script not reaching a goal

0

still, integers do not have property called "value". They dont have any properties at all