#Help needed with currency script.
15 messages · Page 1 of 1 (latest)
{}
?
please learn some basic lua concepts
nah
Code for collecting the collectibles:
local toolName = "CoinCollector"
local currency = "Coin"
local function collectItem(obj, otherPart)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player then
if player.Character:FindFirstChild(toolName) then
local amount = obj.Amount.Value
obj:Destroy()
player.leaderstats[currency].Value += amount
end
end
end
for _, obj in pairs(folder:GetChildren()) do
if obj:IsA("Model") and obj:FindFirstChild("Hit") then
obj.Hit.Touched:Connect(function(otherPart)
collectItem(obj, otherPart)
end)
end
end```
well here it is anywyas
would i add the table in this scritp?
like add an if statement before the the collect item function