My script for a slot machine isn't working. When the button in the Bilboard GUI is clicked, the below dosen't run. I am new to scripting and this is mostly based on wiki/stack exchange/ Dev page info.
local player = game.Players.LocalPlayer
local textLabel = script.Parent
local toggled = false
local button = script.Parent
textLabel.Text = "Click to Play for 5 Cash!"
slot1Combos = {"Bar", "Seven", "Seven", "Seven", "Cherry", "Cherry", "Cherry", "Cherry", "Orange", "Orange", "Orange", "Orange", "Orange", "Lemon", "Lemon", "Lemon", "Lemon", "Lemon", "Banana", "Banana", "Banana", "Banana", "Banana"}
slot2Combos = {"Bar", "Seven", "Cherry", "Cherry", "Cherry", "Orange", "Orange", "Orange", "Orange", "Orange","Orange","Lemon", "Lemon", "Lemon", "Lemon", "Lemon", "Lemon", "Banana", "Banana", "Banana", "Banana", "Banana", "Banana"}
slot3Combos = {"Bar", "Seven", "Cherry", "Cherry", "Cherry", "Orange", "Orange", "Orange", "Orange", "Orange","Orange","Lemon", "Lemon", "Lemon", "Lemon", "Lemon", "Lemon", "Banana", "Banana", "Banana", "Banana", "Banana", "Banana"}
local function onButtonActivated()
if toggled == false then
toggled = true
x = math.random(1,23)
y = math.random(1,23)
z = math.random(1,23)
g = false
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value - 5
if slot1Combos[math.floor(x)] == "Bar" and slot2Combos[math.floor(y)] == "Bar" and slot3Combos[math.floor(z)] == "Bar" then
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 60
textLabel.Text = "You Got 3 Bars. You won 60 cash"
wait(5)
textLabel.Text = "Click to Play for 5 Cash!"
elseif slot1Combos[math.floor(x)] == "Seven" and slot2Combos[math.floor(y)] == "Seven" and slot3Combos[math.floor(z)] == slot2Combos[math.floor(y)] then
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 40
textLabel.Text = "You Got 3 Sevens. You won 40 cash"
wait(5)
textLabel.Text = "Click to Play for 5 Cash!"
elseif slot1Combos[math.floor(x)] == slot2Combos[math.floor(y)] and slot3Combos[math.floor(z)] == slot2Combos[math.floor(y)] then
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 10
textLabel.Text = "You Got 3 of a Kind. You won 10 cash"
wait(5)
textLabel.Text = "Click to Play for 5 Cash!"
elseif slot1Combos[math.floor(x)] == "Cherry" and slot2Combos[math.floor(y)] == "Cherry" and slot3Combos[math.floor(z)] == "Cherry" then
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 20
textLabel.Text = "You Got 3 Cherries. You won 20 cash"
wait(5)
textLabel.Text = "Click to Play for 5 Cash!"
elseif slot1Combos[math.floor(x)] == "Cherry" and slot2Combos[math.floor(y)] == "Cherry" or slot3Combos[math.floor(z)] == "Cherry" and slot1Combos[math.floor(x)] == "Cherry" or slot2Combos[math.floor(y)] == "Cherry" then
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 3
textLabel.Text = "You Got 2 Cherries. You won 3 cash"
wait(5)
textLabel.Text = "Click to Play for 5 Cash!"
elseif slot1Combos[math.floor(x)] == "Cherry" or slot2Combos[math.floor(y)] == "Cherry" or slot3Combos[math.floor(y)] == "Cherry" then
player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 3
textLabel.Text = "You Got 1 Cherry. You won 3 cash"
else
textLabel.Text = "Sorry, you didn't win"
wait (5)
textLabel.Text = "Click to Play for 5 Cash!"
end
end
button.Activated:Connect(onButtonActivated)
end)
This is the explorer tree with the script highlighted
