What's up Jakob lol, I see you on here a lot. Anyway, the reason your script didn't work is because gui.object position requires 4 numbers. It goes like
guiobject.position = UDim2.new(x_screenscale, x_pixels, y_screenscale, y_pixels)
That's what they mean by UDim2. The error you got is because math.random works with 2 numbers. Inside the parentheses after math.random is the maximum and minimum values. So that's like
math.random(minvalue, maxvalue)
Anyway, your code should work if you do math.random on the x and y screen scale values. I don't know the correct term for those values if you haven't guess already. Anyway, it should look something like this.
local x = math.random(0,100)
x = (x*0.01)
local y = math.random(0,100)
y = (y*0.01)
script.Parent.Position = UDim.new(x, 0, y, 0)
I'm not 100% sure that this is going to work but the reason I made the values variables is so I can use math.random with large values because I don't think math.random can do decimals. If it can, then I don't know how to do that lol. Anyway, after you do math.random to get your number, you would then multiply it by 0.01 so that the final value is in between 0 and 1. 0 being the left side of the screen or the top and 1 being the right side of the screen or the bottom. If you find that the frame or whatever goes outside of the screen, just change the random min and max values to your liking. Let me know if you have any questions (can't guarantee that I can answer them though lol).
1 comment
It even says it in the error (expected, got UDim2)