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.

5 comments
Do some rubber-ducky debugging. Why isn't it working? Is the server script even getting triggered? Is the if-then scope running? Add prints everywhere, it'll show you how the code is flowing and help you troubleshoot your problem.
Its very obvious that it's not working because when I click on the item to purchase it with the correct value so I can actually buy the item, I do not receive the item upon clicking.
And I know of no way to detect anything upon clicking, except for the dev console which brings nothing up when I look.
In every TextButton there will be an object called Price?
'v.Name' and 'v.Price', if those are intValue or StringValue, then you might want to change 'v.Name' if you're using StringValue. maybe u r confused or idk