Attempt to perform arithmetic (div) on UDim and number

I’m trying to change the position of a frame, I want to divide the number I get by 2 so my script works on all scales. I don’t really understand the error. All I know from looking at other forums’ posts is that I may be using the wrong method.

Error message
Players.LiquifySlashes.PlayerGui.MinimapV1.ImageLabel.LocalScript:663: attempt to perform arithmetic (div) on UDim and number

Code

Ppos.Position = UDim2.new(0.5, -0.35+(v2_position.x) * (RenderImage.Size.X / 2), 0.5, -1.55+(v2_position.y) * (RenderImage.Size.X / 2))

v2_position and RenderImage are Vector2 positions

1 Like

you need to do v2_position.x.Offset and this is suppossed to not have decimals in the offset

Error:
attempt to index number with ‘Scale’

Ppos.Position = UDim2.new((v2_position.x.Offset) * (RenderImage.Size.X / 2), (v2_position.y.Offset) *(RenderImage.Size.X / 2))

Doesn’t work if I did it correctly.

You either have to put .Scale or .Offset at the end of that. For example:

RenderImage.Size.X.Scale or RenderImage.Size.X.Offset.

It depends which one you wanna use, but if you don’t know already:

Edit: I just read you said RenderImage was a vector position. My fault. However it still seems that RenderImage is the issue at hand, considering its the error comes from dividing something.

Can you maybe look for what RenderImage is initialized as?

1 Like

It didn’t solve it but it was beneficial and helped me solve a little of it though, Thanks!

1 Like

With great help from Nico aka 1nicopatty, I found the solution to my problem. Which first was not using scale at the right position then not knowing how to find the middle of the map but here is the finale string of code.

Ppos.Position = UDim2.new(0.5+(v2_position.X) * (RenderImage.Size.X.Scale / 2), 0.5, 0.5+(v2_position.Y) * (RenderImage.Size.Y.Scale / 2), 0.5)