Hi, so ive been trying to make this script for like an hour(headache) but couldn’t . What im trying to do is spawn a random number ranging from 1 to 7(7 spawns on every tree/bush) of random types of fruit spawn on every tree.
Current code on server script:
local CollectionService = game:GetService("CollectionService")
for i, v in pairs(workspace:GetDescendants()) do
if CollectionService:HasTag(v, "FruitTree") then
local Tree = v
local Spawns = Tree:FindFirstChild("Spawns")
if Spawns then
if not Spawns:FindFirstChildOfClass("BasePart") then
for i, spawnAmount in pairs(Spawns:GetChildren()) do
local RanSpawnAmount = math.random(1, i)
for count = 0, RanSpawnAmount, 1 do
for i, berries in pairs(game.ServerStorage.Berries:GetDescendants()) do
if berries:IsA("BasePart") then
local clone = berries:Clone()
clone.Position = spawnAmount.Position
clone.Anchored = true
clone.Parent = spawnAmount
end
end
end
end
end
end
end
end