Okay so im not sure how to make it so that it stops the script if you don't have enough money, heres the script
debounce = false function onClicked(plr) if not debounce then debounce = true print(plr.Name.." is playing") script.Parent.SlotMachine:Play() script.Parent.Parent.Sign.GUI.SurfaceGui.TextLabel.Text = "Rolling..." script.Parent.Parent.Indicator.BrickColor = BrickColor.new("Institutional white") local stats = plr:findFirstChild("leaderstats") --Find moneyholder if stats ~= nil then --If moneyholder exists then local m = stats:findFirstChild("Cash") --Get money print(plr.Name.." has "..m.Value.." money") m.Value = m.Value - 10 --increase amount of money by the number displayed here (500000) end wait(1) local x = math.random(1,9) local y = math.random(1,9) local z = math.random(1,9) print(x) print(y) print(z) script.Parent.Parent.Num1.SurfaceGui.TextLabel.Text = (tostring(x)) script.Parent.Parent.Num2.SurfaceGui.TextLabel.Text = (tostring(y)) script.Parent.Parent.Num3.SurfaceGui.TextLabel.Text = (tostring(z)) if x == y and x == z and y == z then print("3 Match") script.Parent.Parent.Indicator.BrickColor = BrickColor.new("Lime green") script.Parent.Parent.Sign.GUI.SurfaceGui.TextLabel.Text = "JACKPOT!" script.Parent.BigWin:Play() if stats ~= nil then --If Cashholder exists then local m = stats:findFirstChild("Cash") --Get money print(plr.Name.." has "..m.Value.." Cash") m.Value = m.Value + 110 --increase amount of money by the number displayed here (500000) end elseif x == z then print("2 Match") script.Parent.Parent.Indicator.BrickColor = BrickColor.new("Bright yellow") script.Parent.Parent.Sign.GUI.SurfaceGui.TextLabel.Text = "ONE PAIR!" script.Parent.Jackpot:Play() if stats ~= nil then --If moneyholder exists then local m = stats:findFirstChild("Cash") --Get money print(plr.Name.." has "..m.Value.." Cash") m.Value = m.Value + 30 --increase amount of money by the number displayed here (500000) end elseif y == z then print("2 Match") script.Parent.Parent.Indicator.BrickColor = BrickColor.new("Bright yellow") script.Parent.Parent.Sign.GUI.SurfaceGui.TextLabel.Text = "ONE PAIR!" script.Parent.Jackpot:Play() if stats ~= nil then --If moneyholder exists then local m = stats:findFirstChild("Cash") --Get money print(plr.Name.." has "..m.Value.." Cash") m.Value = m.Value + 30 --increase amount of money by the number displayed here (500000) end elseif x == y then print("2 Match") script.Parent.Parent.Indicator.BrickColor = BrickColor.new("Bright yellow") script.Parent.Parent.Sign.GUI.SurfaceGui.TextLabel.Text = "ONE PAIR!" script.Parent.Jackpot:Play() if stats ~= nil then --If moneyholder exists then local m = stats:findFirstChild("Cash") --Get money print(plr.Name.." has "..m.Value.." Cash") m.Value = m.Value + 30 --increase amount of money by the number displayed here (500000) end else print("No match") script.Parent.Parent.Indicator.BrickColor = BrickColor.new("Really red") script.Parent.Parent.Sign.GUI.SurfaceGui.TextLabel.Text = "TRY AGAIN!" end debounce = false end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
I added an if statement on line 20 to check if the player has enough money. If the player doesn't have enough money, then the script will stop running.
debounce = false function onClicked(plr) if not debounce then debounce = true print(plr.Name.." is playing") script.Parent.SlotMachine:Play() script.Parent.Parent.Sign.GUI.SurfaceGui.TextLabel.Text = "Rolling..." script.Parent.Parent.Indicator.BrickColor = BrickColor.new("Institutional white") local stats = plr:findFirstChild("leaderstats") --Find moneyholder if stats ~= nil then --If moneyholder exists then local m = stats:findFirstChild("Cash") --Get money print(plr.Name.." has "..m.Value.." money") if m.Value < 10 then return end -- If the player's money is less than 10, then stop running the script. m.Value = m.Value - 10 --increase amount of money by the number displayed here (500000) end wait(1) local x = math.random(1,9) local y = math.random(1,9) local z = math.random(1,9) print(x) print(y) print(z) script.Parent.Parent.Num1.SurfaceGui.TextLabel.Text = (tostring(x)) script.Parent.Parent.Num2.SurfaceGui.TextLabel.Text = (tostring(y)) script.Parent.Parent.Num3.SurfaceGui.TextLabel.Text = (tostring(z)) if x == y and x == z and y == z then print("3 Match") script.Parent.Parent.Indicator.BrickColor = BrickColor.new("Lime green") script.Parent.Parent.Sign.GUI.SurfaceGui.TextLabel.Text = "JACKPOT!" script.Parent.BigWin:Play() if stats ~= nil then --If Cashholder exists then local m = stats:findFirstChild("Cash") --Get money print(plr.Name.." has "..m.Value.." Cash") m.Value = m.Value + 110 --increase amount of money by the number displayed here (500000) end elseif x == z then print("2 Match") script.Parent.Parent.Indicator.BrickColor = BrickColor.new("Bright yellow") script.Parent.Parent.Sign.GUI.SurfaceGui.TextLabel.Text = "ONE PAIR!" script.Parent.Jackpot:Play() if stats ~= nil then --If moneyholder exists then local m = stats:findFirstChild("Cash") --Get money print(plr.Name.." has "..m.Value.." Cash") m.Value = m.Value + 30 --increase amount of money by the number displayed here (500000) end elseif y == z then print("2 Match") script.Parent.Parent.Indicator.BrickColor = BrickColor.new("Bright yellow") script.Parent.Parent.Sign.GUI.SurfaceGui.TextLabel.Text = "ONE PAIR!" script.Parent.Jackpot:Play() if stats ~= nil then --If moneyholder exists then local m = stats:findFirstChild("Cash") --Get money print(plr.Name.." has "..m.Value.." Cash") m.Value = m.Value + 30 --increase amount of money by the number displayed here (500000) end elseif x == y then print("2 Match") script.Parent.Parent.Indicator.BrickColor = BrickColor.new("Bright yellow") script.Parent.Parent.Sign.GUI.SurfaceGui.TextLabel.Text = "ONE PAIR!" script.Parent.Jackpot:Play() if stats ~= nil then --If moneyholder exists then local m = stats:findFirstChild("Cash") --Get money print(plr.Name.." has "..m.Value.." Cash") m.Value = m.Value + 30 --increase amount of money by the number displayed here (500000) end else print("No match") script.Parent.Parent.Indicator.BrickColor = BrickColor.new("Really red") script.Parent.Parent.Sign.GUI.SurfaceGui.TextLabel.Text = "TRY AGAIN!" end debounce = false end end script.Parent.ClickDetector.MouseClick:connect(onClicked)