UPDATE: Solved by instead of Remove() the part, setting its Parent = nil works.
When the player clicks on a part, it will walk to that part and get its leaderstat update. When the part is removed and spawned a new one, the player is not walking over to the new part when clicking it. The new part does have the ClickDetector in it. It works for the first initial spawn only. Can you help me see what's wrong here?
local flowers = game.ReplicatedStorage.Flowers.level1:GetChildren()
local selection = math.random(1,#flowers)
local Clone = flowers[selection]:Clone()
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = Clone
ClickDetector.MaxActivationDistance = 500
while true do
wait(1)
if Clone.Parent == nil then
Clone.Parent = workspace.Flowers.level1
local spawners = workspace.Spawners.level1:GetChildren()
local spawnSelection = math.random(1,#spawners)
local spawner = spawners[spawnSelection]
Clone.CFrame = spawner.CFrame + Vector3.new(math.random(-5,5),1,math.random(-5,5))
ClickDetector.MouseClick:Connect(function(playerWhoClicked)
local target = Clone
playerWhoClicked.Character.Humanoid:MoveTo(target.Position,target)
wait(1)
target:Remove()
local flowerValue = playerWhoClicked.leaderstats.Flowers
local coinsValue = playerWhoClicked.leaderstats.Coins
flowerValue.Value = flowerValue.Value + 1
coinsValue.Value = coinsValue.Value + 5
end)
end
end

3 comments
I'm not good in MoveTo, but I do know, for a fact that the player(Humanoid) needs to see the brick after it has spawned. Try putting in a Wait in somewhere.
Putting a wait right after it spawns a new one doesn't work. Putting a wait after the click function end doesn't work, neither. I can't put the local ClickDetector inside the loop because when I do that, it multiplies inside the part.
I also set debounce before and after the player clicks the part, but that doesn't solve the problem.