What is the most efficient way to use a textbutton

Hello scripters, I have a question about the TextButton, when I want to detect if the player clicks on it, the most efficient way is 1 or 2 and why?

Number 1

local textButton = script.Parent
 
local counter = 0
textButton.Text = "Click me!"
 
local function onActivated()
	counter = counter + 1
	textButton.Text = "Clicks: " .. counter
end
 
textButton.Activated:Connect(onActivated)

Number 2

local textButton = script.Parent

local counter = 0
textButton.Text = "Click me!"

textButton.MouseButton1Click:Connect(function()
	counter = counter + 1
	textButton.Text = "Clicks: " .. counter
end)
1 Like

Usualmente uso el método número 2 ya que es eficiente y mucho más fácil de escribir. El método número 1 requiere que conozcas los parámetros de la función.

1 Like