Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The gambling mechanic i experimented with is not working?

So i was experimenting and i made a gambling mechanic, but when i tested it out i would "win" but it would still say i lost, and i thought i would ask here why.

It all mainly happens at the end of the code

local brick = script.Parent
local ClickDectector = brick.ClickDetector
local InUse = false

ClickDectector.MouseClick:connect(function(player)
	local Money = player.leaderstats.Money
	if InUse == false then
		if Money.Value >= 10 then
		InUse = true
		Money.Value = Money.Value - 10
		for Gamble = 1,10 do
			wait(.1)
			print(Gamble)
			brick.BrickColor = BrickColor.Random()
		end
		print("The Pointer Landed On: ") 
		print(brick.BrickColor)

		if brick.BrickColor == "Really red" then
			print("U WIN")
			Money.Value = Money.Value + 1000
		else
			print("you lose hah")
		end
		InUse = false
	end
	if brick.BrickColor == "Really blue" then
		print("U WIN")
		Money.Value = Money.Value + 1000
	else
		print("you lose hah")
	end
		end
end)

2 answers

✓ Accepted answer

Hey buddy just know that making gambling games is against roblox rules if the gambling currency can be purchased with robux. If this is your case, instead make it not buyable with robux, or make a separate currency exclusively for gambling where in no way you can obtain more via robux. An example of that would be a currency converter, e.g you can get 50 gambling currency for 10 main currency, if the main currency is buyable you will still not follow the rules.

But the issue is how you're comparing brick colors. Brick colors are BrickColors, not strings, but BrickColors fortunately have a Name property.

So replace every occurrence of brick.BrickColor == " with brick.BrickColor.Name ==

When checking the BrickColor in an if statement, after the sign, you're supposed to have BrickColor.new(color).

local brick = script.Parent
local ClickDectector = brick.ClickDetector
local InUse = false

ClickDectector.MouseClick:connect(function(player)
    local Money = player.leaderstats.Money
    if InUse == false then
        if Money.Value >= 10 then
        InUse = true
        Money.Value = Money.Value - 10
        for Gamble = 1,10 do
            wait(.1)
            print(Gamble)
            brick.BrickColor = BrickColor.Random()
        end
        print("The Pointer Landed On: ") 
        print(brick.BrickColor)

        if brick.BrickColor == BrickColor.new("Really red") then
            print("U WIN")
            Money.Value = Money.Value + 1000
        else
            print("you lose hah")
        end
        InUse = false
    end
    if brick.BrickColor == BrickColor.new("Really blue") then
        print("U WIN")
        Money.Value = Money.Value + 1000
    else
        print("you lose hah")
    end
        end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.