Im trying to make a script for my simulator for when you buy the next item on the shop you lose the other item and cant buy the lower tier item again i also want to make it so you cant skip a item in the shop so you have to rank up in swords for example: Ninja Legends
What I do is check what text the button is. If it is equip, fire a remote event and then on the server, clone it to the player. (Make sure to implement security check)
after you verify a tool has been bought just destroy the current tool from the player’s backpack, or if there’s multiple types of tools then use string manipulation to some extent; for example considering a player can only carry one type of sword, and one type of explosive, you could name all swords with the prefix ‘sword’ so that when a sword has been bought you would do something like
local function OnSwordPurchased(toolName)
for _,t in ipairs(player.Backpack:GetChildren()) do
if t.Name:match("sword") then
t:Destroy()
end
end
Container[toolName]:Clone().Parent = player.Backpack
end
so any tool that has ‘sword’ in its name will be destroyed, but the explosive would remain