How to constantly update using UserInputService

Hello! I want to make this button update by 1 every time I click it. I don’t know how to script so please bare with me. Currently I have this. (localscript inside of the TextButton)

local Input = game:GetService("UserInputService")

local function onInputEnded(inputObject,)
	
	if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
		script.Parent.Text = "You clicked 1 time"
	end
end

image

Any help is appreciated. Thanks!

1 Like

If you want to see when the TextButton is clicked, you can just use the TextButton.Activated event, like this :

local TotalClicks = 0

script.Parent.Activated:Connect (function ()
	TotalClicks += 1
	
	if TotalClicks == 1 then
		script.Parent.Text = "You've clicked 1 time"
		
	else
		script.Parent.Text = "You've clicked " .. TotalClicks .. " times"
		
	end
end)
1 Like