Cant index x , when using clamp

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By StsDevSquad

So I have a node with a sprite with the following code

        extends Node2D

onready var sprite = $Sprite

func set_marker_position(bounds: Rect2):
	sprite.global_position.x = clamp(global_position.x, bounds.x, bounds.end.x)
	sprite.global_position.y = clamp(global_position.y, bounds.y, bounds.end.y)

I keep getting a error that says cant get index x on base rect2

:bust_in_silhouette: Reply From: jgodfrey

Yeah, that error makes sense. If you look at the docs for Rect2, you’ll see that it doesn’t have an x property.

I assume you’re looking for bounds.position.x and bounds.position.y.