"NotEnoughCash" Sound Plays Even when i Buy something with enough Cash?
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:
01 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
02 | local remoteEvent = ReplicatedStorage:WaitForChild( "BuyTool" ) |
04 | local BuySound = ReplicatedStorage:WaitForChild( "PlayBuySound" ) |
05 | local NotEnoughSound = ReplicatedStorage:WaitForChild( "PlayNotEnoughSound" ) |
07 | local function buyTool(player, tool) |
08 | if (player.Backpack:FindFirstChild(tool.Name)) then return end |
09 | if player.leaderstats [ "????" ] .Value > = tool.Price.Value then |
11 | player.leaderstats [ "????" ] .Value = player.leaderstats [ "????" ] .Value - tool.Price.Value |
13 | local giveTool = ReplicatedStorage.ShopItems [ tool.Name ] :Clone() |
14 | giveTool.Parent = player.Backpack |
16 | local giveTool = ReplicatedStorage.ShopItems [ tool.Name ] :Clone() |
17 | giveTool.Parent = player.StarterGear |
19 | BuySound:FireClient(player) |
22 | if player.leaderstats [ "????" ] .Value < = tool.Price.Value then |
23 | NotEnoughSound:FireClient(player) |
29 | remoteEvent.OnServerEvent:Connect(buyTool) |