Game Boundaries Script

Hi everyone,
I’m trying to add boundaries to my screen so my character doesn’t fall off the edge of the game.
This is the code I’m trying to get to work and the error I’m receiving is “no overload for method clamp takes two arguments”. I added in floats as it wouldn’t let me put the positions in otherwise, but not sure how to get it to work? I’m very new to coding so please be nice :stuck_out_tongue:

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

public class Boundaries : MonoBehaviour
{
    public float gameBoundaryX = -0.41f;
    public float gameBoundaryY = 4.12f;
    // Start is called before the first frame update
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
        transform.position = new Vector3(Mathf.Clamp(transform.position.x, gameBoundaryX),
            Mathf.Clamp(transform.position.y, gameBoundaryY), transform.position.z);
    }
}

Clamp takes three arguments. You probably meant something like this

        transform.position = new Vector3(Mathf.Clamp(transform.position.x, 0, gameBoundaryX),
            Mathf.Clamp(transform.position.y, 0, gameBoundaryY), transform.position.z);