Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a text that shows the CPS?

Asked by 3 years ago
Edited 3 years ago

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

1 answer

Log in to vote
1
Answered by 3 years ago
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
Ad

Answer this question