A way to interact with UI Button: Click on UI Buttons with mouse

GUIDE TITLE: This is about creating ui in CORE
ESTIMATED COMPLETION TIME: 3 min
CORE VERSION: 2.2.14.0

SUGGESTED PREREQUISITES: Key Binding List - Core Documentation

TUTORIAL SUMMARY:
Interact with GUI in Core using bindingPressedevent

EXPECT TO LEARN:
Interact with GUI
Click a Button

END PRODUCT VISUALS:

TUTORIAL:

script.parent.clickedEvent:Connect(function()
print("button pressed")
end)

--toggle mouse visibility when left ctrl is pressed by player
--left ctrl=="ability_extra_10"
local player=Game.GetLocalPlayer()
local ctrlpressed=false
player.bindingPressedEvent:Connect(function(player,pressedkey)
  if pressedkey=="ability_extra_10"then
    if ctrlpressed==false then
        ctrlpressed=true
        UI.SetCursorVisible(true)
    else
        ctrlpressed=false
        UI.SetCursorVisible(false)
    end
  end
end)```
1 Like

Thank you so much!

1 Like