I’m making a game that measures your CPS (Clicks Per Second). Everything is going well, but I found something I want to change, which is estimating, or rounding, to make it an integer.
I have done my research but just can’t find anything about the topic.
local cps = script.Parent.TextLabel
local button = script.Parent.TextButton
local start = script.Parent.Start
start.MouseButton1Click:Connect(function()
print("3")
wait(1)
print("2")
wait(1)
print("1")
wait(1)
print("CLICK!")
for count = 1, 4, 1 do
button.MouseButton1Click:Connect(function()
button.TextLabel.Text = button.TextLabel.Text + 1/3
end)
end
wait(3)
button.TextLabel.Text = button.TextLabel.Text / 3
cps.Text = button.TextLabel.Text
game.Players.LocalPlayer:Kick("You have got a total CPS of "..cps.Text.."! Rejoin if you want to test again.")
end)
Thank you for taking the time to read the current problem I’m having!
local cps = script.Parent.TextLabel
local button = script.Parent.TextButton
local start = script.Parent.Start
local decimalPlaces = 0 -- Any number between 0 and 2
start.MouseButton1Click:Connect(function()
print("3")
wait(1)
print("2")
wait(1)
print("1")
wait(1)
print("CLICK!")
for count = 1, 4, 1 do
button.MouseButton1Click:Connect(function()
button.TextLabel.Text = button.TextLabel.Text + 1/3
end)
end
wait(3)
button.TextLabel.Text = button.TextLabel.Text / 3
local Clicks = button.TextLabel.Text
Clicks*= 10^decimalPlaces
Clicks+=0.5
Clicks = math.floor(clicks)
Clicks /= 10^decimalPlaces
cps.Text = Clicks
game.Players.LocalPlayer:Kick("You have got a total CPS of "..cps.Text.."! Rejoin if you want to test again.")
end)