roblox on button click 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: lua how to make a click to activate button

script.Parent.MouseButton1Click:Connect(function()
--What ever you want to do
end)

Tags:

Lua Example