Put buttons around jump button / walk button

Hey! I want to make my game mobile-friendly, which means I can’t put guis at the lower left and right corners. Other games (like roblox bedwars) have buttons around the jump button. How do I position buttons around the jump button in a circle? I saw this post where they put a button on top of and left of the jump button, but what if I want to put something diagonally across?

Example:


The sword button is at the top left side of the jump button. How do I use code to position it there? Thank you so much!

2 Likes

To position buttons around the jump button in a circle, you can use the following approach:

  1. Calculate the position of each button relative to the center of the circle.
  2. Use the “Position” property of each button to position them at their respective coordinates.
  3. Use trigonometry to calculate the X and Y coordinates of each button relative to the center of the circle.
  4. Use the “AnchorPoint” property of each button to center them on their respective coordinates.

Here’s an example of how you can use trigonometry to position a button at a 45-degree angle from the jump button:

local jumpButton = -- get the jump button object
local angle = math.rad(45) -- convert the angle to radians
local radius = 50 -- set the radius of the circle
local x = jumpButton.Position.X + radius * math.cos(angle)
local y = jumpButton.Position.Y + radius * math.sin(angle)
local newButton = Instance.new("TextButton") -- create a new button
newButton.Position = UDim2.new(0, x, 0, y) -- set its position
newButton.AnchorPoint = Vector2.new(0.5, 0.5) -- center it on its position
newButton.Parent = -- parent the button to the GUI

You can repeat this process for each button, using a different angle for each one to position them evenly around the circle.

1 Like

by the way, I realized that the radius for each devices is a little different. How do I get the radius size if the jump button’s size is different?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.