So I am trying to make it that when a player doesn’t has enough cash to buy something then he will be notified that works just fine. But when a player has enough cash for it but he buys something else first, then his cash will be getting lowered. But when he first got enough cash for it it will say ‘This will cost 300$ are you sure?’ But he actually doesn’t haves enough cash so technically it has to say this ‘You dont have enough cash to buy this’ but he is not saying that cause his cash was first higher then the amount.
Can someone help me with this?
If you need the script here it is;
local leaderstats = player.leaderstats local hover = game.SoundService.HoverSound if Cash.Value < 300 then -- checks if the cash is under 300 script.Parent.Parent.Text = "You don't have enough cash to buy this!" -- sets the text to this script.Parent.Text = "Close" else script.Parent.Parent.Text = "This will cost: $300 Are you sure?" end script.Parent.MouseEnter:Connect(function() hover:Play() end) script.Parent.MouseButton1Click:Connect(function(click) if Cash.Value < 300 then warn("You dont have enough cash") script.Parent.Parent.Visible = false else script.Parent.Parent.Text = "This will cost: $300 Are you sure?" script.Parent.Text = "Purchase" script.Parent.Purchase.Disabled = true -- disables the script print("PurchaseScript has been disabled") -- prints what happening Cash.Value = Cash.Value - 300 -- sets the cash to min 300 print("leaderstats has been changed with -300") script.Parent.Parent.Visible = false script.Parent.Parent.Parent.BackGround.Philips.PriceSetter.Visible = true script.Parent.Parent.Parent.BackGround.Philips.Selection.Visible = false wait(5) local philipsclone = game.ReplicatedStorage.Tvs.Philipstv1.PartsOfPhilips:Clone() philipsclone.Parent = game.Workspace local position = game.ReplicatedStorage.Tvs.Philipstv1.PartsOfPhilips.Screen -- dit en de regel eronder is voor de positie waar hij word gecloned dus in de machine for i, v in pairs(philipsclone:GetChildren()) do v.Anchored = false v.CanCollide = true v.Transparency = 0 end -- positions local rotatepositionCFrame = CFrame.Angles(0,math.rad(0), 0) position.CFrame = position.CFrame:ToWorldSpace(rotatepositionCFrame) print("The CFrame has been set") wait(10) wait(30) print("30 Seconds are over!") script.Parent.Parent.Parent.BackGround.Philips.PriceSetter.Visible = false script.Parent.Parent.Parent.BackGround.Philips.Selection.Visible = true script.Disabled = false print("PurchaseScript has been enabled") game.StarterGui.ComputerMenu.Menu1.Philips1Info.PurchaseChecker.Purchase.Purchase.Disabled = false end end)