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:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("BuyTool") local BuySound = ReplicatedStorage:WaitForChild("PlayBuySound") local NotEnoughSound = ReplicatedStorage:WaitForChild("PlayNotEnoughSound") local function buyTool(player, tool) if (player.Backpack:FindFirstChild(tool.Name)) then return end if player.leaderstats["????"].Value >= tool.Price.Value then player.leaderstats["????"].Value = player.leaderstats["????"].Value - tool.Price.Value local giveTool = ReplicatedStorage.ShopItems[tool.Name]:Clone() giveTool.Parent = player.Backpack local giveTool = ReplicatedStorage.ShopItems[tool.Name]:Clone() giveTool.Parent = player.StarterGear BuySound:FireClient(player) end if player.leaderstats["????"].Value <= tool.Price.Value then NotEnoughSound:FireClient(player) end end remoteEvent.OnServerEvent:Connect(buyTool)