Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.