Coin Magnet Problem

Hi, so I’m working on this endless runner project, and the coin magnet powerup works well.

But there is one problem, when the coins get attracted, they sometimes don’t get consumed by the player, sometimes it’s because they fall behind due to the player’s speed.
And so the coins are in the wrong position when the game recalls the past sections.
I have tried changing the attractionspeed to a higher or lower number, but it hasn’t helped.
I’m hoping someone can help me fix my issue.
Thanks in advance.

Screenshots of the coins being in the wrong position after being recalled in the sections:

You can replace Vector3.MoveTowards with Vector3.Lerp, which will give you smoother interpolation towards the player’s position over time. Probably MoveTowards is not fast enough, so better make mganetic effect time-based, not speed-based

using UnityEngine;

public class MagnetActive : MonoBehaviour
{
    private GameObject player;
    public float attractionSpeed = 50f;
    public float magnetRange = 10f;
    private float lerpTime = 0f;  // Time counter for lerping

    void Start()
    {
        // For Magnet
        player = GameObject.FindGameObjectWithTag("Player");
    }

    void Update()
    {
        if (MagnetActivation.isMagnetActive == true)
        {
            MoveTowardsPlayer();
        }
    }

    public void MoveTowardsPlayer()
    {
        if (Vector3.Distance(transform.position, player.transform.position) < magnetRange)
        {
            // Increase the lerpTime based on attraction speed
            lerpTime += attractionSpeed * Time.deltaTime;

            // Lerp the position towards the player
            transform.position = Vector3.Lerp(transform.position, player.transform.position, lerpTime);
        }
    }
}

Thank you for your response.
It was stupid of me actually. You see the coins re-enable after a time of being collected, so they would be collected on the player and re-enabled there as well.
I have to find a new way to generate the coins.