I am trying to thread a function for each minion in the world. But it only seems to thread once. I don't really know what the problem is.
here is how it works.
--server script
local function minionThinker (plr,minion)
--setup functions
while true do
if not minion then return end
wait(0.01)
end
end)
------------------------------
players.PlayerAdded:Connect(function(plr)
if not plr then return end
local playerMinions = Minions:WaitForChild(plr.Name)
for i,minion in pairs(playerMinions:GetChildren())do
spawn(minionThinker(plr,minion))--> coonects the minion thinker function
print("minion added")
end
playerMinions.DescendantAdded:Connect(function(des)
spawn(minionThinker(plr,des))
print("Minion added")
end)
end)
I will also show you how the adding of the minions work
--module script
function module.CreateMinion (plr,minionName)
if ServerMinions:FindFirstChild(minionName)then
if plr then
for I = 1,10 do
local serverCopy = serverMinions:FindFirstChild(minionName):Clone()
serverCopy.Parent = minionFolder:FindFirstChild(plr.Name)
wait(0.001)
print(#minionFolder:GetChildren())--> only prints "1" ten times
end
end
end
end
