#Pls help me im new to coding
25 messages · Page 1 of 1 (latest)
but what tho ive tried that
could you show the whole function?
wht do u mean by that?
like copy and paste the whole code for the function you made or screenshot of it
i copy it hold on
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FormatNumber = require(ReplicatedStorage.Libs.FormatNumber.Simple)
local Remote = ReplicatedStorage.Remotes
local Gui = script.Parent
local Frame = Gui.Frame
local Power = Frame.Power.Amount
local ClicksPerSec = Frame.Power.CPS
local BuyClicks = Frame.Power.Buy
local Rebirths = Frame.Rebirths.Amount
local ClicksDuringSecond = 0
local PreviousClicksAmount = 0
local CLICKS_PER_SECOND_STRING_TEMPLATE = "(+AMOUNT/sec)"
local function UpdateClicksPerSecond(amount: number)
local amountOfClicks = amount - PreviousClicksAmount
PreviousClicksAmount = amount
if amountOfClicks <= 0 then return end
ClicksDuringSecond += amountOfClicks
ClicksPerSec.Text = CLICKS_PER_SECOND_STRING_TEMPLATE:gsub("AMOUNT", FormatNumber.FormatCompact(ClicksDuringSecond))
ClicksPerSec.Visible = true
task.delay(1, function()
ClicksDuringSecond -= amountOfClicks
ClicksPerSec.Text = CLICKS_PER_SECOND_STRING_TEMPLATE:gsub("AMOUNT", FormatNumber.FormatCompact(ClicksDuringSecond))
ClicksPerSec.Visible = ClicksDuringSecond > 0
end)
local function UpdateCurrency(currency: "Power" | "Rebirths", amount: number)
if currency == "Power" then
UpdateClicksPerSecond(amount)
Power.Text = FormatNumber.FormatCompact(amount)
elseif currency == "Rebirths" then
Rebirths.Text = FormatNumber.FormatCompact(amount)
end
end
UpdateCurrency("Power", Remote.GetData:InvokeServer("Power"))
Remote.UpdateClicks.OnClientEvent:Connect(function(amount)
UpdateCurrency("Power", amount)
end)
thats the code
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FormatNumber = require(ReplicatedStorage.Libs.FormatNumber.Simple)
local Remote = ReplicatedStorage.Remotes
local Gui = script.Parent
local Frame = Gui.Frame
local Power = Frame.Power.Amount
local ClicksPerSec = Frame.Power.CPS
local BuyClicks = Frame.Power.Buy
local Rebirths = Frame.Rebirths.Amount
local ClicksDuringSecond = 0
local PreviousClicksAmount = 0
local CLICKS_PER_SECOND_STRING_TEMPLATE = "(+AMOUNT/sec)"
local function UpdateClicksPerSecond(amount: number)
local amountOfClicks = amount - PreviousClicksAmount
PreviousClicksAmount = amount
if amountOfClicks <= 0 then return end
ClicksDuringSecond += amountOfClicks
ClicksPerSec.Text = CLICKS_PER_SECOND_STRING_TEMPLATE:gsub("AMOUNT", FormatNumber.FormatCompact(ClicksDuringSecond))
ClicksPerSec.Visible = true
task.delay(1, function()
ClicksDuringSecond -= amountOfClicks
ClicksPerSec.Text = CLICKS_PER_SECOND_STRING_TEMPLATE:gsub("AMOUNT", FormatNumber.FormatCompact(ClicksDuringSecond))
ClicksPerSec.Visible = ClicksDuringSecond > 0
end)
local function UpdateCurrency(currency: "Power" | "Rebirths", amount: number)
if currency == "Power" then
UpdateClicksPerSecond(amount)
Power.Text = FormatNumber.FormatCompact(amount)
elseif currency == "Rebirths" then
Rebirths.Text = FormatNumber.FormatCompact(amount)
end
end
UpdateCurrency("Power", Remote.GetData:InvokeServer("Power"))
Remote.UpdateClicks.OnClientEvent:Connect(function(amount)
UpdateCurrency("Power", amount)
end)
Just formatting
So ppl see clearer
k
where?
** You are now Level 1! **
local function UpdateClicksPerSecond(amount: number)
local amountOfClicks = amount - PreviousClicksAmount
PreviousClicksAmount = amount
if amountOfClicks <= 0 then return end
ClicksDuringSecond += amountOfClicks
ClicksPerSec.Text = CLICKS_PER_SECOND_STRING_TEMPLATE:gsub("AMOUNT", FormatNumber.FormatCompact(ClicksDuringSecond))
ClicksPerSec.Visible = true
task.delay(1, function()
ClicksDuringSecond -= amountOfClicks
ClicksPerSec.Text = CLICKS_PER_SECOND_STRING_TEMPLATE:gsub("AMOUNT", FormatNumber.FormatCompact(ClicksDuringSecond))
ClicksPerSec.Visible = ClicksDuringSecond > 0
end)
local function UpdateCurrency(currency: "Power" | "Rebirths", amount: number)
if currency == "Power" then
UpdateClicksPerSecond(amount)
Power.Text = FormatNumber.FormatCompact(amount)
elseif currency == "Rebirths" then
Rebirths.Text = FormatNumber.FormatCompact(amount)
end
end
UpdateCurrency("Power", Remote.GetData:InvokeServer("Power"))
Remote.UpdateClicks.OnClientEvent:Connect(function(amount)
UpdateCurrency("Power", amount)
end)
end
it shouldnt show any errors now
U forgot to close the updateclicksersecond
oh ok ill try it
Is this supposed to be one whole function called updateclickspersecond
Did it work tho
yh there are no errors