If someone buys something from this shop, they will get their item, but if you respawn, they lose their gear and also you can't buy 2 of the same item and I don't know the fix. This is the script for when you press the button to buy it.
script.Parent.MouseButton1Click:Connect(function()
local plr = game.Players.LocalPlayer
local Points = plr.leaderstats.Points
if Points.Value >= 500 then
local Event = game.ReplicatedStorage.Purchased
Event:FireServer("GravityCoil", 500)
end
end)
Also, here is another, so can someone help me with the gear being kept when respawned and maybe tell me how to make someone be able to buy more of the same item.?
local CountName = "Points"
game.Players.PlayerAdded:connect(function(Player)
local leaderstats = Player:FindFirstChild('leaderstats') or Instance.new("Folder", Player)
leaderstats.Name = "leaderstats"
local Points = leaderstats:FindFirstChild(CountName) or Instance.new("IntValue", leaderstats)
Points.Name = CountName
Points.Value = 0
Player.CharacterAdded:connect(function(Character)
local d = true
Character:WaitForChild("Humanoid").Died:connect(function()
if (d) then
d = false
Points.Value = Points.Value + 100
local CloneMe = game.StarterGui.Shop:Clone()
CloneMe.Parent = Player.PlayerGui
end
end)
end)
end)
-------------------- New Function
game.ReplicatedStorage.Purchased.OnServerEvent:Connect(function(plr,Message,Cost)
local Item = game.ServerStorage:FindFirstChild(Message)
local Points = plr.leaderstats.Points
Points.Value = Points.Value - Cost
Item:Clone()
Item.Parent = plr.Backpack
end)

2 comments
Is there a starter pack for individual players? I think you can add an item to a players starter pack and then when they re-spawn they will have it but i'm not completely sure
also does this give any errors?