ProximityShop that has saving, and equipping

I am trying to make a shop similar to Slap Battles.

I have the purchasing down, but I am trying to figure out how to make it save, and to make the prompt turn into an Equip instead of Purchase.

Here’s a basic script that is in the workspace, under a pedestal part, I have 24 of these so it might take some time to change them lol

script.Parent.Triggered:Connect(function(plr)
	local points = plr.leaderstats.points
	if points.Value >= 50 then
		points.Value = points.Value - 50
		local storage = game:GetService("ServerStorage")
		
		for _, tool in pairs(plr.Backpack:GetChildren()) do
			if tool:IsA("Tool") then
				tool:Destroy()
			end
		end
		for _, tool in pairs(plr.StarterGear:GetChildren()) do
			if tool:IsA("Tool") then
				tool:Destroy()
			end
		end
		storage["Weapon"]:Clone().Parent = plr.Backpack
		storage["Weapon"]:Clone().Parent = plr.StarterGear
	end
end)

I’m sorry I’ve been making so many posts recently I am just trying to figure many things out.

You can use datastores to save the items

Well I knew that, but I don’t know how to script it.

i recommend grabbing a leaderboard datastore script (cus datastores are a pain to learn) and modifying it so that it saves two folders with equipped items & their owned items

sure it may not be good practice but it works

btw u should use ipairs instead of pairs their more optimized and

points.Value -= 50

instead of

points.Value = points.Value - 50