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

How do I do for my script to see all Berrys -money - being sold not just for a certain amount?

Asked by 6 years ago
Edited 6 years ago

This is my script

local player = game.Players.LocalPlayer
local coins = player:WaitForChild("leaderstats"):WaitForChild("Berrys")
local gold = player:WaitForChild("leaderstats"):WaitForChild("Gold")
local enabled = false

script.Parent.MouseButton1Click:connect(function()
    enabled = false
    if coins.Value < 100 then return end
    enabled = true
    coins.Value = coins.Value - 50
    gold.Value = gold.Value + 10
end)

I want to know if I can change the value of <100 to any number but the value of the sale is equal to that of gold

Ex: If I have 1 Berrys (Money), then I win 1 Gold (Money) if I have 4 Berrys i win for 4 Gold and so on

Just like simulator games, you sell what you took for money****

1 answer

Log in to vote
0
Answered by 6 years ago

Depending on how you set your berries up, if each berry is an item in the player inventory/backpack you could try

for i, item in pairs(player.Backpack:GetChildren()) do -- The parameter is wherever the berries are stored
    if item.Name == 'Berry' then
        --do this for every berry
    end
end
Ad

Answer this question