Position of image label

I want to set the position of an image label with a random value. This is the script that I have and the error I get is below. I have tried switching “offset” to “scale” but it won’t work.

	spiny.Position.X.Offset = randomx:NextNumber(0.023, 0.884)
	spiny.Position.Y.Offset = randomy:NextNumber(0.034, 0.461)

image

you have to set position like this

spiny.Position =
    UDim2.new(
    randomx:NextNumber(0.023, 0.884), -- Scale
    spiny.Position.X.Offset, -- Offset
    randomy:NextNumber(0.034, 0.461), -- Scale
    spiny.Position.Y.Offset -- Offset
)
spiny.Position =
		UDim2.new(
			Random:NextNumber(0.023, 0.884), -- Scale
			spiny.Position.X.Offset, -- Offset
			Random:NextNumber(0.034, 0.461), -- Scale
			spiny.Position.Y.Offset -- Offset
		)


Line twelve is Random:NextNumber(0.023, 0.884), – Scale

The position X/Y Scale/Offset properties are read-only. To change a UIObject(such as an image) position, you must change the position as a whole using the UDim2 constructor:

local X = randomx:NextNumber(0.023, 0.884)
local Y = randomy:NextNumber(0.034, 0.461)
spiny.Position = UDim2.fromScale(X, Y)