unity2d teleports my object to wrong coordinates

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IdealneKolko : MonoBehaviour
{
    Vector2 pos;
    public GameObject kolko;
    public bool clickedB;
    private void Start()
    {
       kolko.transform.position = new Vector2(Random.Range(-214, 222), Random.Range(238, -553));
    }
    private void Update()
    {
        if (clickedB == true)
        {
            kolko.transform.position = new Vector2(Random.Range(-214, 222), Random.Range(238, -553));
            clickedB = false;
        }
    }
    public void clicked()
    {
        clickedB = true;
    }
}

,HI i have this script in unity and it works good theoretically but unity idk why when i use random position it teleports my object on coordinates 1000 2000 suppose and i set it max to 500 400.
Im trying to fix it but idk how ?

Is this gameobject a child of another gameobject? If so, you may want to use transform.LocalPosition. The difference is that transform.position moves in what we call “World Space”. That is, they are absolute coordinates. If your game object is a child, then it’s current transform.position is relative to the parent, which we call “Local Space”

If you set transform.localPosition, you are moving relative to the parent, which is what you normally want when moving a child.

Firstly, your setup seems like it could be optimised. Try and get that click event into an actual one-time click event rather than in Update with a bool. That could easily cause unexpected behaviour with variable framerates.

Secondly, how is your object setup? Is it parented under another? There is also no need to have a public variable for “kolko”. Simply call “transform.position” or “transform.localPosition” and make sure the script is on that “kolko” object.