Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

math.random relative to persons screen size?

I would like the image to be placed randomly across the screen but keep it relative to the players window so even if they resized it it would fill from the left border to the right border, but by doing (0,1) it only places on either the right side or left side. So i was wondering if anyone had a solution for this

		local t = tick()
		for i = 1, 5 do
			local bubble = Instance.new("ImageLabel")
			bubble.Name = "bubble"
			bubble.Position = UDim2.new(math.random(0, 1), 0, 0, 0)
			bubble.Size = UDim2.new(0, 100, 0, 100)
			bubble.Parent = Player.PlayerGui.Loading.Frame
			bubble.Visible = true
		end

edit: this is the line im talking about

bubble.Position = UDim2.new(math.random(0, 1), 0, 0, 0)

1 comment

0

I'm also wondering if there's a possibility i can use camera.viewportsize? but im not sure how to implement it

1 answer

✓ Accepted answer

I can't exactly do what your asking for but this might be a solution that you want

local t = tick()
for i = 1, 5 do
    local bubble = Instance.new("ImageLabel")
    bubble.Name = "bubble"
    bubble.Position = UDim2.new(math.random(1, 100) / 100, 0, 0, 0)--we get a random number 1 to 100 and divide it
    bubble.Size = UDim2.new(0, 100, 0, 100)
    bubble.Parent = Player.PlayerGui.Loading.Frame
    bubble.Visible = true
end

1 comment

0

thank you so much i didn't even think about that

This discussion is preserved as it was. New answers, comments, and votes are closed.