Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a text that shows the CPS?

I want to make a frame with a text that shows the players Clicks Per Second. How can I script it?

1 answer

✓ Accepted answer
local userInputService = game:GetService("UserInputService") -- get UIS service so you can detect when player clicks the LMB

local textLabel = script.Parent.TextLabel -- change to path of textLabel
local clicks = 0 -- set up variable for number of clicks

userInputService.InputBegan:Connect(function(input) -- detect when player inputs something 
	if input.UserInputType == Enum.UserInputType.MouseButton1 then -- check if input is LMB
		clicks += 1 -- add 1 to number of clicks
	end
end)

while wait(1) do -- loop function every second
	textLabel.Text = clicks -- change text to number of clicks
	clicks = 0 -- reset clicks to 0
end

This discussion is preserved as it was. New answers, comments, and votes are closed.