So I have a script that when a part gets clicked it runs the rest of the script and does a slot machine-like thing, but now it won't run again after it is clicked once and finished the slot stuff. Code:

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=1976242599", --Coin
"http://www.roblox.com/asset/?id=1976271649", --Gem
"http://www.roblox.com/asset/?id=1976243494", --Face
"http://www.roblox.com/asset/?id=1976244535", --Sword
"http://www.roblox.com/asset/?id=1976120686"} --Controller

local Alarm1 = script.Parent.Alarm1
local Alarm2 = script.Parent.Alarm2
local CoinClone = script.Parent.CoinClone
local Pull1 = script.Parent.Pull1
local Pull2 = script.Parent.Pull2
local CD = script.Parent.Pull1.Click.ClickDetector
local WinSound = script.Parent.Logo.Win

local S1 = script.Parent.S1.Decal
local S2 = script.Parent.S2.Decal
local S3 = script.Parent.S3.Decal

function Alarm()
	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
end

function Coin()
	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
end

---------------------------------------------------------------
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
end



if S1.Texture == Images[1] and S2.Texture == Images[1] and S3.Texture == Images[1] then
	PlayWin()
	Alarm()
	Coin()
	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 == Images[2] and S2.Texture == Images[2] and S3.Texture == Images[2] then
	PlayWin()
	Alarm()
	Coin()
	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 == Images[3] and S2.Texture == Images[3] and S3.Texture == Images[3] then
	PlayWin()
	Alarm()
	Coin()
	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 == Images[4] and S2.Texture == Images[4] and S3.Texture == Images[4] then
	PlayWin()
	Alarm()
	Coin()
	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 == Images[5] and S2.Texture == Images[5] and S3.Texture == Images[5] then
	PlayWin()
	Alarm()
	Coin()
	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)

The Game is FE btw.

1 comment

0

I think you have too many "End"s in the last couple lines