Help in Buy All button

from previous post, line 48 will being restore

at line 48
if v.order.Value == nextnumber-1 then
-- this make the only latest tool will be cloned into the player's inventory.

and insert function that destroy previous tool (at line 55)

for i,v in pairs(plr.Backpack:GetChildren()) do -- line 55
	if v:FindFirstChild("order") and v.order.Value < nextnumber-1 then
		v:Destroy()
		-- it will destroy only tool that have "order" value, like a previous tool
		-- if player have other tool like boombox, it will not being destroy
	end
end
game.ReplicatedStorage.Remotes.BUYTOOL:FireClient(plr , item) -- this line not changed

hope that work :innocent:

1 Like

Hello, it works now but it completely breaks my other scripts

Could you explain more which is break or could you show an error from the output?

So basically lets say i have 99b currency, the tool costs 100b currency. It buys the tool and it breaks my text update text and there is no errors in output

never mind it works now thank you for solving my problem : )

Hi, i was wondering how can i subtract the currency from the player? I tried adding this line of code at line 56

	plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value - v.Cost.Value

maybe add at line 24, it will subtract from player, all of tool player can afford (equal to manually buy all)

Thank you now it works perfectly

Dont forget to mark a solution as Solved so that others will know that the topic is already solved.

1 Like