roblox button pressed code example
Example 1: how to execute scripts when a button gui is pressed roblox
function leftClick()
print("Left mouse click")
end
function rightClick()
print("Right mouse click")
end
script.Parent.MouseButton1Click:Connect(leftClick)
script.Parent.MouseButton2Click:Connect(rightClick)
Example 2: roblox key pressed script
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.KeyDown:connect(function()
print("Pressed a key.")
end)