Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Shop GUI Item loads in studio, but not in game?

Asked by 5 years ago

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.

0
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. ScrewDeath 153 — 5y
0
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. LordBlueSky 10 — 5y
0
And I know of no way to detect anything upon clicking, except for the dev console which brings nothing up when I look. LordBlueSky 10 — 5y
0
In every TextButton there will be an object called Price? User#19524 175 — 5y
0
'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 User#17685 0 — 5y

Answer this question