Open Sourced The Buttons From Ultimate Boxing

Example place:

For Ultimate Boxing, I had a special button creator exclusively for creating buttons that don’t look ugly and have native controller support, and did a better job of scaling on mobile (ex: borders). After a rewrite, I now have a public version of it.

Here is what some of them look like without a controller:

And here is what they look like with a controller:

For a bit of example code, here is what the code for the orange button looks like:

[code]
local ButtonClass = require(game.ReplicatedStorage:WaitForChild(“ButtonClass”))

local Button = ButtonClass.new()
Button.BorderColor3 = Color3.new(1,0.5,0)
Button.BackgroundColor3 = Color3.new(1,0.7,0)
Button.Size = UDim2.new(0.2,0,0.05,0)
Button.AnchorPoint = Vector2.new(0.5,0.5)
Button.Position = UDim2.new(0.75,0,0.25,0)
Button.SizeConstraint = “RelativeYY”
Button.Text = “Test”
Button.Font = “SourceSansBold”
Button.TextScaled = true
Button.TextColor3 = Color3.new(1,1,1)
Button.TextStrokeColor3 = Color3.new(0,0,0)
Button.TextStrokeTransparency = 0
Button.Name = “TestButton”
Button.BorderSizeScale = 0.05
Button.TextPadding = UDim.new(0.05,0)
Button.ControllerIconType = “ButtonX”
Button.ControllerInput = Enum.KeyCode.ButtonX
Button.ControllerIconPosition = “Right”
Button.Parent = script.Parent

Button.MouseButton1Down:connect(function()
Button.BackgroundColor3 = Color3.new(math.random(),math.random(),math.random())
Button.BorderColor3 = Color3.new(math.random(),math.random(),math.random())
end)[/code]

Also, this was my first main “test” with meta tables, and I think it came out pretty well. Actually was able to get the module to support most of Roblox’s default API for TextButtons without having write code for each property and function. :wink:

19 Likes

Pretty cool

Also, here’s a picture that’s not as pixelated

Image ![|690x462](upload://ppaVcefpFHogfazJgj4sZE83vAC.jpeg)

I would suggest that you merged ControllerIconType and ControllerInput into just ControllerInput, as you can get the icon from the enum.
Also, Button:IsA(“CustomButton”) returns false - you need a self 1st argument here?

I would argue that you wouldn’t need a whole ~535 lines of code for that class as well, but I’m assuming most of it comes from the new properties, methods and cross-platform support. Either way, it looks pretty useful as an overall themed button :grin:

1 Like

I actually didn’t do this because I did have a few cases where I wanted the button to show but not have it register MouseButton1Down (ex: In the Ultimate Boxing shop, I have the left and right bumper show but it just moves between the 3 rather than activate them).

Oops, I will fix that.
Edit: Fixed

1 Like