#I have a problem in my code. Can someone please help me ?

18 messages · Page 1 of 1 (latest)

chilly mist
#

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Remotes = ReplicatedStorage.Remotes

local Gui = script.Parent
local Frame = Gui.Frame

local Clicks = Frame.Clicks.Amount
local ClicksPerSec = Frame.Clicks.CPS
local BuyClicks = Frame.Clicks.Buy
local Gems = Frame.Gems.Amount

local function UpdateCurrency(currency: "Clicks" | "Gems", amount: number)
if currency == "Clicks" then
Clicks.Text = amount
elseif currency == "Gems" then
Gems.Text = amount
end
end

Remotes.UpdateClicks.OnClientEvent:Connect(function(amount)
UpdateCurrency("Clicks", amount {it says this ,,amount" word is the problem })
end)

This is the code and it says that the ,,amount" word next to the { sign is the problem. someone please help.

wooden mortar
#

Wrong. It's currency: string

you can't specify what string.

#

@chilly mist

chilly mist
#

Wait wdym

#

Sorry but im new to coding

#

I started like 4 days ago

#

And im just learning from yt tutorials so idk if thats the best source

heavy field
wooden mortar
heavy field
#

No it should still work.

#

Works for me and I have letter for letter the same script.

#

He needs to add this line: "amount = if amount then amount else 0"

#

local function UpdateCurrency(currency: "Clicks" | "Gems", amount: number)
amount = if amount then amount else 0
if currency == "Clicks" then
Clicks.Text = amount

#

Like that ^

chilly mist
#

I finally solved it

#

Thank you guys @wooden mortar @heavy field

#

But I got a problem still

wheat ironBOT
#

studio** You are now Level 1! **studio