Script doesn't work even thought there is no errors at all

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!

Impossible without knowing what it’s supposed to do. Did you write it?

yes, i wrote the script myself, i can send the whole script of you want… maybe i messed something up.

!! UPDATE !!

i fixed it, no worries. thanks for the support!

Can you tell us what it was supposed to do? It’ll help people in the future with the same issue.

Also share your fix if possible.

the script that I sent was fine. the other part of script was broken, that’s why it didn’t work. sorry!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.