#how do i make my gambling script 😭

1 messages · Page 1 of 1 (latest)

pale plank
#

im a complete beginner and just learnt about math.random so i tried making a script that makes another part cycle through some colors by clicking another part and then make another part the color of what they win, like 60% is flint color or whatever but i just cant get it working 😭

spiral chasm
#

uh

abstract stagBOT
#

studio** You are now Level 2! **studio

spiral chasm
#

i'll rewrite that for you

cold holly
#

spoonfeeding

spiral chasm
#

yes

#

i'll explain it tho

pale plank
rain sky
#

you missed an end

#

why is there an if true then

pale plank
remote mauve
#

I love gambling

rain sky
pale plank
#

nothing in output

spiral chasm
#
local clickdetector = script.Parent.ClickDetector
local youcanclick = true
local winnoti = workspace.gambling.Winnoti
local noti = workspace.gambling.Noti

local colors = { -- you can put the colors in a table like this
    BrickColor.new("Flint"),
    BrickColor.new("Pastel Blue"),
    BrickColor.new("Bright red"),
    BrickColor.new("New Yeller"),
    BrickColor.new("Pearl")
}

clickdetector.MouseClick:Connect(function()
    if youcanclick then -- this works too and takes up less space
        
        for MyCounter = 1, 5 do -- the default increcement is 1
            task.wait(0.1)
            noti.BrickColor = colors[math.random(1,#colors)] -- this takes one random color from the table we made, and sets noti's color to it
        end
        
        local chance = math.random(1, 100)
        
        if chance >= 60 then
            winnoti.BrickColor = colors[1] -- sets winnoti's color to the first color in the same table
        elseif chance <= 19  and chance <= 59 then -- use elseif instead of just "if"
            winnoti.BrickColor = colors[2] 
        elseif chance <= 3 and chance >= 18 then
            winnoti.BrickColor = colors[3] 
        elseif chance <= 39 and chance >= 50 then
            winnoti.BrickColor = colors[4] 
        elseif chance <= 0 and chance >= 2 then -- you set the color to bright red in both of these scenarios in your version
            winnoti.BrickColor = colors[5]     
        end
        
        wait(0.2)
        
        -- the "winnoti.BrickColor = BrickColor.new("Pearl") will make the color end up the same everytime
        -- ,so we remove that
        
        youcanclick = true
    end
end)
rain sky
#

oh i see

#

you forgot else

spiral chasm
#

one second i forgot to test it

#

alright it works

#

if you were trying to make it do something different, tell me

pale plank
abstract stagBOT
#

studio** You are now Level 1! **studio

spiral chasm
#

hold up a second

#

i found an error in the logic

#
local clickdetector = script.Parent.ClickDetector
local youcanclick = true
local winnoti = workspace.gambling.Winnoti
local noti = workspace.gambling.Noti

local colors = { 
    BrickColor.new("Flint"),
    BrickColor.new("Pastel Blue"),
    BrickColor.new("Bright red"),
    BrickColor.new("New Yeller"),
    BrickColor.new("Pearl")
}

clickdetector.MouseClick:Connect(function()
    if youcanclick then
        
        for MyCounter = 1, 5 do 
            task.wait(0.1)
            noti.BrickColor = colors[math.random(1,#colors)] 
        end
        
        local chance = math.random(1,100)
        
        if chance >= 60 then
            winnoti.BrickColor = colors[1] 
        elseif chance >= 19  and chance <= 59 then 
            winnoti.BrickColor = colors[2] 
        elseif chance <= 3 and chance >= 18 then
            winnoti.BrickColor = colors[3] 
        elseif chance <= 17 and chance >= 3 then
            winnoti.BrickColor = colors[4] 
        elseif chance <= 2 then 
            winnoti.BrickColor = colors[5]     
        end
        
        wait(0.2)
        youcanclick = true
    end
end)
#

now you can gamble properly

#

@pale plank

noble kiln