In order for me to purchase the item in the Shop GUI, I must set my Coins leaderstats value to 300 as the shop items' price is 300.
When I click on the item to buy it, it works in the studio, deducting the 300 from my balance but not in game.
I am using a datastore, here are the scripts.
I am also using a RemoteEvent as well because I have filtering enabled.
The item script:
for i,v in pairs(script.Parent:GetChildren()) do if v:IsA("TextButton") then v.MouseButton1Click:Connect(function() game.ReplicatedStorage.RemoteEvent:FireServer(v.Name, v.Price) end) end end
The "Communication" script in workspace
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, item, price) if player.leaderstats.Coins.Value >= price.Value then player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - price.Value local ItemClone = game.ServerStorage[item]:Clone() ItemClone.Parent = player:WaitForChild("Backpack") local ItemClone2 = game.ServerStorage[item]:Clone() ItemClone2.Parent = player:WaitForChild("StarterGear") end end)
Please help.