Need some help with a problem I just can’t seem to understand… My goal is when a click detector is pressed that player is checked if they have the required amount of money. Stop If they do continue the script’s functions. If they don’t then don’t continue and stop the script without doing anything. And where and what code to put to give the money earned for winning. I can’t figure out what and where to put the code to check the players money and how to make the script respond to it. If any additional information is needed to help please let me know. Here’s the script:
‘’’
function LeverPull()
script.Parent.Pull1.Click.Transparency =1
script.Parent.Pull1.P1.Transparency = 1
script.Parent.Pull2.P1.Transparency = 0
script.Parent.Pull2.P2.Transparency = 0
wait(0.3)
script.Parent.Pull1.Click.Transparency = 0
script.Parent.Pull1.P1.Transparency = 0
script.Parent.Pull2.P1.Transparency = 1
script.Parent.Pull2.P2.Transparency = 1
end
function PlayWin()
script.Parent.Logo.Win:Play()
wait(1)
script.Parent.Logo.Win:Stop()
end
Images={
“http://www.roblox.com/asset/?id=47671241”,
“http://www.roblox.com/asset/?id=47671036”,
“http://www.roblox.com/asset/?id=47671152”,
“http://www.roblox.com/asset/?id=47671141”}
Alarm1 = script.Parent.Alarm1
Alarm2 = script.Parent.Alarm2
CoinClone = script.Parent.CoinClone
Pull1 = script.Parent.Pull1
Pull2 = script.Parent.Pull2
CD = script.Parent.Pull1.Click.ClickDetector
WinSound = script.Parent.Logo.Win
S1 = script.Parent.S1.Decal
S2 = script.Parent.S2.Decal
S3 = script.Parent.S3.Decal
function onClicked()
CD.MaxActivationDistance = 0
LeverPull()
for i = 1,40 do
wait(0.05)
S1.Texture = Images[math.random(1,#Images)]
S2.Texture = Images[math.random(1,#Images)]
S3.Texture = Images[math.random(1,#Images)]
end
for i = 1,40 do
wait(0.05)
S2.Texture = Images[math.random(1,#Images)]
S3.Texture = Images[math.random(1,#Images)]
end
for i = 1,40 do
wait(0.05)
S3.Texture = Images[math.random(1,#Images)]
end
if S1.Texture == “http://www.roblox.com/asset/?id=47671241” and S2.Texture == “http://www.roblox.com/asset/?id=47671241” and S3.Texture == “http://www.roblox.com/asset/?id=47671241” then
PlayWin()
for i = 1,10 do
wait(0.15)
Alarm1.PointLight.Enabled = true
Alarm1.BrickColor = BrickColor.new(“Really red”)
Alarm2.BrickColor = BrickColor.new(“Really red”)
wait(0.15)
Alarm1.BrickColor = BrickColor.new(“Black”)
Alarm1.PointLight.Enabled = false
Alarm2.BrickColor = BrickColor.new(“Black”)
end
for i = 1,20 do
local Coin = script.Parent.CoinClone:Clone()
Coin.Parent = script.Parent
Coin.Name = “Coin”
Coin.CanCollide = true
Coin.Anchored = false
Coin.Position = script.Parent.CoinClone.Position - Vector3.new(0,1,0)
wait(0.2)
end
wait(5)
for _, child in pairs(script.Parent:GetChildren()) do
if child.Name == ‘Coin’ then
child:Destroy()
else
end
end
CD.MaxActivationDistance = 8
else if S1.Texture == “http://www.roblox.com/asset/?id=47671036” and S2.Texture == “http://www.roblox.com/asset/?id=47671036” and S3.Texture == “http://www.roblox.com/asset/?id=47671036” then
PlayWin()
for i = 1,10 do
wait(0.15)
Alarm1.PointLight.Enabled = true
Alarm1.BrickColor = BrickColor.new(“Really red”)
Alarm2.BrickColor = BrickColor.new(“Really red”)
wait(0.15)
Alarm1.BrickColor = BrickColor.new(“Black”)
Alarm1.PointLight.Enabled = false
Alarm2.BrickColor = BrickColor.new(“Black”)
end
for i = 1,20 do
local Coin = script.Parent.CoinClone:Clone()
Coin.Parent = script.Parent
Coin.Name = “Coin”
Coin.CanCollide = true
Coin.Anchored = false
Coin.Position = script.Parent.CoinClone.Position - Vector3.new(0,1,0)
wait(0.2)
end
wait(5)
for _, child in pairs(script.Parent:GetChildren()) do
if child.Name == ‘Coin’ then
child:Destroy()
else
end
end
CD.MaxActivationDistance = 8
else if S1.Texture == “http://www.roblox.com/asset/?id=47671152” and S2.Texture == “http://www.roblox.com/asset/?id=47671152” and S3.Texture == “http://www.roblox.com/asset/?id=47671152” then
PlayWin()
for i = 1,10 do
wait(0.15)
Alarm1.PointLight.Enabled = true
Alarm1.BrickColor = BrickColor.new(“Really red”)
Alarm2.BrickColor = BrickColor.new(“Really red”)
wait(0.15)
Alarm1.BrickColor = BrickColor.new(“Black”)
Alarm1.PointLight.Enabled = false
Alarm2.BrickColor = BrickColor.new(“Black”)
end
for i = 1,20 do
local Coin = script.Parent.CoinClone:Clone()
Coin.Parent = script.Parent
Coin.Name = “Coin”
Coin.CanCollide = true
Coin.Anchored = false
Coin.Position = script.Parent.CoinClone.Position - Vector3.new(0,1,0)
wait(0.2)
end
wait(5)
for _, child in pairs(script.Parent:GetChildren()) do
if child.Name == ‘Coin’ then
child:Destroy()
else
end
end
CD.MaxActivationDistance = 8
else if S1.Texture == “http://www.roblox.com/asset/?id=47671141” and S2.Texture == “http://www.roblox.com/asset/?id=47671141” and S3.Texture == “http://www.roblox.com/asset/?id=47671141” then
PlayWin()
for i = 1,10 do
wait(0.15)
Alarm1.PointLight.Enabled = true
Alarm1.BrickColor = BrickColor.new(“Really red”)
Alarm2.BrickColor = BrickColor.new(“Really red”)
wait(0.15)
Alarm1.BrickColor = BrickColor.new(“Black”)
Alarm1.PointLight.Enabled = false
Alarm2.BrickColor = BrickColor.new(“Black”)
end
for i = 1,20 do
local Coin = script.Parent.CoinClone:Clone()
Coin.Parent = script.Parent
Coin.Name = “Coin”
Coin.CanCollide = true
Coin.Anchored = false
Coin.Position = script.Parent.CoinClone.Position - Vector3.new(0,1,0)
wait(0.2)
end
wait(5)
for _, child in pairs(script.Parent:GetChildren()) do
if child.Name == ‘Coin’ then
child:Destroy()
else
end
end
CD.MaxActivationDistance = 8
else
CD.MaxActivationDistance = 8
end
end
end
end
end
Pull1.Click.ClickDetector.MouseClick:connect(onClicked)
‘’’