Robloxでゲーム画面にボタンを表示し、クリックしたらイベントを実行する
ボタンの作成
UIタブを選択し、ScreenGUIをクリックする

ExplorerのStarterGui配下にScreenGuiが作成される

作成されたScreenGuiの右のプラスボタンからTextButtonを作成する

画面左上にボタンが表示された

ボタンの位置を移動してプレイを開始するとボタンに触れることができる

ボタンを押下したときのイベントを登録する
ボタンの配下にLocalScriptを作成し名前をButtonScriptに変更する
以下のように編集する
local button = script.Parent local function onButtonClicked() -- ボタンのテキストを変更する button.Text = "Clicked" end -- ボタンが押されたときのイベントを登録する button.Activated:Connect(onButtonClicked)
結果
