Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Slot Machine spin Button not working? (uses surfacegui)

Asked by 7 years ago
Edited 7 years ago

Ok so I have started revamping one of my old slot machines I added a functional surfacegui menu to it and it works really great so far but I am finding that there is an issue with my first and 2nd script for the spin button below you can find the photos for the error for both scripts and the scripts themselves along with a picture of the workspace drectory! I fixed the errors but now it seems to work but the slot machine will not spin???

Error for Script Two | https://gyazo.com/db283223535663988c50800aa47e801b Error for Script One | https://gyazo.com/a96f4a600e3916d9eadc61d7933aa21d Below is Script Two

amountpay = script.Parent.Parent.Parent.Parent.Require.Value
player = game:GetService("Players").LocalPlayer

script.Parent.MouseButton1Down:connect(function()

if player.leaderstats.Credits.Value >= amountpay then
script.Parent.Parent.Parent.Parent.Main.ClickDetector.MaxActivationDistance = 0
wait(3.5)
script.Parent.Parent.Parent.Parent.Main.ClickDetector.MaxActivationDistance = 15
end

end)

Below is Script One

player =game:GetService("Players").LocalPlayer
slot1 = script.Parent.Parent.Parent.Parent.slot1
slot2 = script.Parent.Parent.Parent.Parent.slot2
slot3 = script.Parent.Parent.Parent.Parent.slot3


Colors = {"Lime green","Really red","New Yeller","Really blue","Bright green","Copper"}
print(Colors[math.random(1,#Colors)])
amountpay = script.Parent.Parent.Parent.Parent.Require.Value
amountwin = amountpay * 10
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = "Require: " .. amountpay ..  "  Reward: " .. amountwin

script.Parent.MouseButton1Down:connect(function(player)
if player.leaderstats.Credits.Value >= amountpay then
player.leaderstats.Credits.Value = player.leaderstats.Credits.Value - amountpay
for i = 1,10 do
wait(.1)
color = Colors[math.random(1,#Colors)]
script.Parent.Parent.slot1.BrickColor = BrickColor.new(color)
color = Colors[math.random(1,#Colors)]
script.Parent.Parent.slot2.BrickColor = BrickColor.new(color)
color = Colors[math.random(1,#Colors)]
script.Parent.Parent.slot3.BrickColor = BrickColor.new(color)
end 

for i = 1,10 do
wait(.1)

color = Colors[math.random(1,#Colors)]
script.Parent.Parent.slot2.BrickColor = BrickColor.new(color)
color = Colors[math.random(1,#Colors)]
script.Parent.Parent.slot3.BrickColor = BrickColor.new(color)
end 

for i = 1,10 do

color = Colors[math.random(1,#Colors)]
script.Parent.Parent.slot3.BrickColor = BrickColor.new(color)
end 

if slot1.BrickColor.Name == "Lime green" and slot2.BrickColor.Name == "Lime green" and slot3.BrickColor.Name == "Lime green" then
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = player.Name .. " Has Won " .. amountwin
player.leaderstats.Credits.Value = player.leaderstats.Credits.Value + amountwin
wait(3)
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = "Require: " .. amountpay ..  "  Reward: " .. amountwin
end
if slot1.BrickColor.Name == "Really red" and slot2.BrickColor.Name == "Really red" and slot3.BrickColor.Name == "Really red" then
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = player.Name .. " Has Won " .. amountwin
player.leaderstats.Credits.Value = player.leaderstats.Credits.Value + amountwin
wait(3)
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = "Require: " .. amountpay ..  "  Reward: " .. amountwin
end
if slot1.BrickColor.Name == "New Yeller" and slot2.BrickColor.Name == "New Yeller" and slot3.BrickColor.Name == "New Yeller" then
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = player.Name .. " Has Won " .. amountwin
player.leaderstats.Credits.Value = player.leaderstats.Credits.Value + amountwin
wait(3)
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = "Require: " .. amountpay ..  "  Reward: " .. amountwin
end
if slot1.BrickColor.Name == "Really blue" and slot2.BrickColor.Name == "Really blue" and slot3.BrickColor.Name == "Really blue" then
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = player.Name .. " Has Won " .. amountwin
player.leaderstats.Credits.Value = player.leaderstats.Credits.Value + amountwin
wait(3)
if slot1.BrickColor.Name == "Bright green" and slot2.BrickColor.Name == "Bright green" and slot3.BrickColor.Name == "Bright green" then
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = player.Name .. " Has Won " .. amountwin
player.leaderstats.Credits.Value = player.leaderstats.Credits.Value + amountwin
wait(3)
if slot1.BrickColor.Name == "Copper" and slot2.BrickColor.Name == "Copper" and slot3.BrickColor.Name == "Copper" then
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = player.Name .. " Has Won " .. amountwin
player.leaderstats.Credits.Value = player.leaderstats.Credits.Value + amountwin
wait(3)
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = "Require: " .. amountpay ..  "  Reward: " .. amountwin
else
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = "You Have Lost"
wait(1)
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = "Require: " .. amountpay ..  "  Reward: " .. amountwin
end



else
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = "Not Enough Credits"
wait(3)
script.Parent.Parent.Parent.Parent.gui.SurfaceGui.TextLabel.Text = "Require: " .. amountpay ..  "  Reward: " .. amountwin
end
end
end
end)

Below is a picture of the directory to make more sense of my script! (Had to break it into two pictures!) https://gyazo.com/1e3c8284d28d009dd9fdecbd52b55c88 https://gyazo.com/f18512fa43d97240c308f9b2bb11f50c

Thank you to who ever answers me in advance!

0
Geez, please look into using actual variables, loops, and functions. cabbler 1942 — 7y

Answer this question