Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

for loop wont spawn npc based on the number if a value?

Asked by 5 years ago

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.

0
the infamount variable is an integer , not an object, meaning it doesnt have a value property theking48989987 2147 — 5y
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. mantorok4866 201 — 5y
0
edit: welp, found out that the script itself isnt being enabled due to another script not reaching a goal mantorok4866 201 — 5y
0
still, integers do not have property called "value". They dont have any properties at all theking48989987 2147 — 5y

Answer this question