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

"NotEnoughCash" Sound Plays Even when i Buy something with enough Cash?

Asked by 4 years ago

When I buy something, a buy sound should play, and when I try to buy something without having the necessary money, an error sound should play and it works but for some reason, the error sound plays even when i buy something with enough cash.

The Script:

01local ReplicatedStorage = game:GetService("ReplicatedStorage")
02local remoteEvent = ReplicatedStorage:WaitForChild("BuyTool")
03 
04local BuySound = ReplicatedStorage:WaitForChild("PlayBuySound")
05local NotEnoughSound = ReplicatedStorage:WaitForChild("PlayNotEnoughSound")
06 
07local function buyTool(player, tool)
08    if (player.Backpack:FindFirstChild(tool.Name)) then return end
09    if player.leaderstats["????"].Value >= tool.Price.Value then
10 
11        player.leaderstats["????"].Value = player.leaderstats["????"].Value - tool.Price.Value
12 
13        local giveTool = ReplicatedStorage.ShopItems[tool.Name]:Clone()
14        giveTool.Parent = player.Backpack
15 
View all 29 lines...
0
im pretty sure you can delete the end on line 21, and edit line 22 so it's "elseif player.leaderstats["????"].Value <= tool.Price.Value". basically what you're doing is checking if the player has enough money, and then checking again if they don't have enough money (even if they already have the money). im not the best explainer but what i said should work meteorcrasher118 35 — 4y
0
It Works!!! Thanks!! benjinanas 50 — 4y

Answer this question