I kinda have 2 questions relating to coding UI for console.
First: I’m using SelectionImageObject
with a frame I have, to replace the neon blue one that is default for SelectedObject
It works to an extent. When I test the Selected frame I’m using is to the right of the text, and at the top of the screen, but when I use the control to go up and down it moves up and down, but in the centre of the screen. The Selected frame is the yellow frame next to the Text. How I move the Selected frame with the mouse (:TweenPosition()) is where I want the Selected frame to be.
Which then leads to my second question: I’m using MouseEnter
and MouseLeave
to do animations to the text (Change the font and move the Selected frame to next to the text) Was wondering if there is a way to do this with console, without detecting if selected = “DeployButton”, selected = “GunsButton”, etc.
Here’s what I have
local guiService = game:GetService('GuiService')
local players = game:GetService('Players')
local userInputService = game:GetService('UserInputService')
local contextActionService = game:GetService('ContextActionService')
local player = players.LocalPlayer
local playerGui = player:WaitForChild('PlayerGui')
local mouse = player:GetMouse()
local frame = script.Parent
local selected = frame:WaitForChild('Selected')
local deployButton = frame:WaitForChild('DeployButton')
local gunButton = frame:WaitForChild('GunButton')
local boostButton = frame:WaitForChild('BoostButton')
local statButton = frame:WaitForChild('StatButton')
playerGui.SelectionImageObject = selected
if userInputService.GamepadEnabled then
guiService:AddSelectionParent('Menu', frame)
guiService.SelectedObject = deployButton
end
deployButton.MouseButton1Down:connect(function()
frame:Destroy()
end)
for _, button in pairs(frame:GetChildren()) do
if button.ClassName == 'TextButton' then
button.MouseEnter:connect(function()
button.Font = 'SourceSansBold'
selected:TweenPosition(UDim2.new(button.Position.X.Scale - 0.25, 0, button.Position.Y.Scale, 0), 'Out', 'Quint', 0.25, true)
end)
button.MouseLeave:connect(function()
button.Font = 'SourceSansSemibold'
end)
end
end