-
What do you want to achieve?
I want to properly scale and position mobile buttons across multiple screen sizes. However, my method is based on a block of code from Roblox’s script responsible for the jump button. -
What is the issue?
Mobile buttons do not scale and position properly.
-
What solutions have you tried so far?
I tested different values but they don’t contribute well to the results. Unfortunately, I cannot understand the structure of the code very well.
local UserInputService = game:GetService("UserInputService")
local Client = game:GetService("Players").LocalPlayer
local GUI = script.Parent
function Setup (Button, minSize, maxSize, minPos, maxPos)
local minAxis = math.min(GUI.AbsoluteSize.X, GUI.AbsoluteSize.Y)
local smallScreen = minAxis <= 500 print(smallScreen)
local buttonSize = smallScreen and minSize or maxSize
Button.Size = UDim2.new(0,buttonSize,0,buttonSize)
Button.Position = smallScreen and minPos or maxPos
end
if UserInputService.TouchEnabled then GUI.Enabled = true
Setup(
GUI.Sprint, 50, 100,
UDim2.new(1, -(50*1.5-10), 1, -50 - 100),
UDim2.new(1, -(100*1.5-10), 1, -100 * 1.75)
)
if Client.UserId == 2962442343 then
Setup(
GUI.Console, 50, 100,
UDim2.new(1, -(50*1.5 - -50), 1, -50 - 100),
UDim2.new(1, -(100*1.5 - -50), 1, 50 * 1.75)
)
GUI.Console.Visible = true
end
end
script:Destroy()