I’ve made this extremely simple random UI position script
local newX = math.random(0.1, 0.9)
local newY = math.random(0.1, 0.9)
script.Parent.Position = UDim2.new(newX, 0, newY, 0)
But for some reason everytime I click On it It decides to go to the position “(0,0)” an exact position not mentioned inside the math.random, any fix? is this a roblox bug?
I don’t think math.random returns numbers only integers so just do math.random(1,9) then divide that by 10
math.random only returns integers according to the documentation
You should rather use the
Random class which allows you to access it’s
local random: Random = Random.new()
local x: number = random:NextNumber(0, 1) -- 0.2917610161522376
i didnt know that, THANK YOU
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.