This is a simple module script that will help you create buttons for any mobile interface.
Buttons can only be located near the jump button along the top edge.
How to create a button?
Step 1
Create a local script in StarterGui and place the module in it.
Step 2
Require the module and create a new button using the following command
local ActionButton = require(script.ActionButton)
-------------------------------------------------
local Button = ActionButton.new()
You’ve created your first button, now let’s style it!
Step 3
For styling we will use the following commands
:SetIcon(Image: string)
Sets an icon, although I think you yourself understood this!
:SetStrokeStyle(Params: {any})
These are normal properties and values in table.
:SetIconStyle(Params: {any})
Another one!
Let’s write some simple code
local ActionButton = require(script.ActionButton)
-------------------------------------------------
local Button = ActionButton.new()
Button
:SetIcon("11932783331")
:SetStrokeStyle {
Thickness = 3,
Transparency = 0,
Color = Color3.fromRGB(255, 170, 0)
}
:SetIconStyle {
ImageColor3 = Color3.fromRGB(255, 170, 0)
}
:SetPadding(10)
Wow! We managed to make the button beautiful, but how to make it work?
Step 4
Let’s make our button work, for this we will use the .Clicked
method
Let’s create a button for endless jumping!
local ActionButton = require(script.ActionButton)
local Player = game.Players.LocalPlayer
local Humanoid = Player.Character:WaitForChild("Humanoid")
-------------------------------------------------
local Button = ActionButton.new()
Button
:SetIcon("11932783331")
:SetStrokeStyle {
Thickness = 3,
Transparency = 0,
Color = Color3.fromRGB(255, 170, 0)
}
:SetIconStyle {
ImageColor3 = Color3.fromRGB(255, 170, 0)
}
:SetPadding(10)
.Clicked:Connect(function()
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end)
Now everything works great!