Hello Devs, I have this script that will loop through all the items inside a folder and then I want to clone and position them, but the script is not working. It will not spawn the part at all nor position it to its right location.
ServerScript
local StarterZoneCurrency = script.Parent
local SpawnPositon = CFrame.new(-222,58,-28) -- Where I want the items to drop
--local SpawnRandom = math.random()
local StarterZoneCurrencyItems = {
StarterZoneCurrency["Bag 1"],
StarterZoneCurrency["Bag 2"],
StarterZoneCurrency["Coin"],
StarterZoneCurrency["Gem"],
StarterZoneCurrency["Chest"]
-- all the items
}
for i,v in pairs(StarterZoneCurrencyItems) do -- looping through the talbe
print(i,v)
while true do
wait(0.2)
local CloneBag1 = StarterZoneCurrencyItems{1}:Clone()
CloneBag1.Parent = game.Workspace
CloneBag1:PrimaryPartCFrame(SpawnPositon)
-- the script stops working here and the the Bag does not appear
end
end
There is not errors in the script