Hey, I’m having a problem, this part of the script just doesn’t work, no errors, nothing. could somebody please explain or help me with this problem? I think the problem is corountine.wrap, but I’m not sure.
elseif selectedmod.name == "city" then
for _, v in pairs(game.Workspace.Map.Plates:GetChildren()) do
if v.Name == "Plate" then
coroutine.wrap(function()
local rand = math.random(1,2)
if rand == 1 then
local tower = game.ReplicatedStorage.Assets.Objects.Tower:Clone()
tower.Parent = v
while game.ReplicatedStorage.Round.Value == true do
tower:SetPrimaryPartCFrame(v.Part.CFrame + Vector3.new(0,00.5 + v.Part.Size.Y/2,0))
task.wait()
end
elseif rand == 2 then
local tree = game.ReplicatedStorage.Assets.Objects.Tree:Clone()
tree.Parent = v
local minX = v.Part.Position.X - v.Part.Size.X / 2 + 2
local maxX = v.Part.Position.X + v.Part.Size.X / 2 - 2
local minZ = v.Part.Position.Z - v.Part.Size.Z / 2 + 2
local maxZ = v.Part.Position.Z + v.Part.Size.Z / 2 - 2
local randomX = math.random(minX, maxX)
local randomZ = math.random(minZ, maxZ)
while game.ReplicatedStorage.Round.Value == true do
tree:SetPrimaryPartCFrame(v.Part.Position + Vector3.new(randomX, v.Part.Size.Y/2, randomZ))
task.wait()
end
end
end)()
end
end
Thanks!