Hi guys, I've built a script for an ingame shop GUI that allows players to buy gear with "points" which is a leaderstats currency and is saved using datastores. However, i've noticed a major issue with this script which is that when a player leaves the game or dies, the gear they purchased is removed from their inventory and they'd have to buy it again. Here is my script so far...
player = game.Players.LocalPlayer
points = player.leaderstats.Points
price = script.Parent.Cost.Value
tool = game.Lighting.Tools.Speedcoil
function buy()
if points.Value >= price then
points.Value = points.Value - price
local a = tool:clone()
a.Parent = player.Backpack
local b = tool:clone()
b.Parent = player.StarterGear
end
end
script.Parent.MouseButton1Down:Connect(buy)
Please note that this is inside a localscript.
Any help is appreciated!

1 comment
unaccepting cus just spoon feeding full code