I made this store gui were you have a certain number of coins, then you are able to buy a gun. But the problem is, you buy the gun and it stays in your inventory forever. So my players, will be buying a lot of items, but with it doing this the items will pile in the inventory. However, if i can script this "on mouseclick1 remove item" without charging player again. Then "on mouseclick1 add item" something like that. so the first time it charges you once it know the item has been bought it will activate the equip and unequip. Has anyone worked with this? if so could you share some facts so i can get this complete?
local player = game.Players.LocalPlayer
local leaderboard = player:WaitForChild("leaderstats")
local button = script.Parent
local price = button:WaitForChild("Price")
local item = button:WaitForChild("ItemName")
local rs = game:GetService("ReplicatedStorage")
button.MouseButton1Click:connect(function()
if leaderboard.Coins.Value >= price.Value then -- Change "Coins" to your currency name...
leaderboard.Coins.Value = leaderboard.Coins.Value - price.Value
local item = rs:WaitForChild(item.Value)
item:Clone().Parent = player.StarterGear
item:Clone().Parent = player.Backpack
end
end)
while wait() do
button.Text = item.Value.." - "..price.Value
end

2 comments
Thxs
No problem, glad I could help!