I have a store UI working, but I want it so the player can only have one item, so it destroys everything in their backpack and clones the new tool back into the backpack.
The issue is I don’t know how to do this, as I never had this problem before. Even if this is super simple.
I’ve tried if statements, or even just trying to destroy the whole backpack, and just clone the other tools I don’t want to destroy back into the backpack. But, I don’t know a reasonable way to approach this.
Here is the server script:
local replicatedStorage = game:GetService("ReplicatedStorage")
local serverStorage = game:GetService("ServerStorage")
local weights = serverStorage.Weights
replicatedStorage.Remotes.Info.OnServerInvoke = function(player, item)
return weights[item].Points.Value
end
replicatedStorage.Remotes.Sale.OnServerInvoke = function(player, item)
local price = weights[item].Points.Value
if player.leaderstats.Money.Value >= price then
player.leaderstats.Money.Value = player.leaderstats.Money.Value - price
player.StarterGear:Destroy()
local tool = weights[item][item]:Clone()
tool.Parent = player.StarterGear
return true
else
return false
end
end
Anything helps! Thanks. ![]()