This only makes 1 zombie go to the position i want all the zombies there help?
local items = game.Workspace:GetChildren() for i,k in pairs(items) do if k.Name == "Zombie" then wait(5) BP = Instance.new("BodyPosition") BP.Name = "BoPo" BP.maxForce = Vector3.new(1000000, 1000000, 1000000) BP.position = script.Parent.Position BP.Parent = k.Torso wait(8) k.Torso.BoPo:remove() end end
Simple, define BP locally:
local items = game.Workspace:GetChildren() for i,k in pairs(items) do if k.Name == "Zombie" then wait(5) local BP = Instance.new("BodyPosition") BP.Name = "BoPo" BP.maxForce = Vector3.new(1000000, 1000000, 1000000) BP.position = script.Parent.Position BP.Parent = k.Torso wait(8) k.Torso.BoPo:remove() end end
Turns out, it works just fine. I just tested it. Do you mean why does it only fetch one zombie at a time? Cause it gets them all. If so, then use coroutines:
local items = game.Workspace:GetChildren() for i,k in pairs(items) do if k.Name == "Zombie" then coroutine.resume(coroutine.create(function(a) wait(5) local BP = Instance.new("BodyPosition") BP.Name = "BoPo" BP.maxForce = Vector3.new(1000000, 1000000, 1000000) BP.position = script.Parent.Position BP.Parent = a.Torso wait(8) k.Torso.BoPo:remove() end),k) end end