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

Help Work[sp].Touch Tesla Gate.Main:16: 'end' expected (to close 'function' at line 13) near 'else'?

Asked by 6 years ago

I don't understand where to put the 'end' as I have been trying for the past hour.

local Mode = 1

local Button = script.Parent.Button.Button
local OnlineLight = script.Parent.Online
local OfflineLight = script.Parent.Offline
local Electricity = script.Parent.Electricity
local Detector = script.Parent.Detector
local Main = script.Parent

local Debounce = false


Button.Touched:connect(function(Player)
    if Debounce then return end
    Debounce = true
        else if Mode == 1 then
        wait(3)
        Electricity.ComingOnline:Play()
        wait(0.85)
        Electricity.Humming:Play()
        script.Parent.EmitterTest.a.ParticleEmitter.Enabled = true
        script.Parent.EmitterTest.b.ParticleEmitter.Enabled = true
        script.Parent.EmitterTest.c.ParticleEmitter.Enabled = true
        script.Parent.EmitterTest.d.ParticleEmitter.Enabled = true
        script.Parent.EmitterTest.e.ParticleEmitter.Enabled = true
        script.Parent.EmitterTest.f.ParticleEmitter.Enabled = true
        Mode = 2
        if Mode == 2 then
        wait(3)
        Electricity.GoingOffline:Play()
        wait(0.85)
        script.Parent.EmitterTest.a.ParticleEmitter.Enabled = false
        script.Parent.EmitterTest.b.ParticleEmitter.Enabled = false
        script.Parent.EmitterTest.c.ParticleEmitter.Enabled = false
        script.Parent.EmitterTest.d.ParticleEmitter.Enabled = false
        script.Parent.EmitterTest.e.ParticleEmitter.Enabled = false
        script.Parent.EmitterTest.f.ParticleEmitter.Enabled = false
        Electricity.Humming:Stop()
        Mode = 1
    end
    wait(0.4)
    Debounce = false
end

Spawn(function()
    while wait(0.5) do
        if Mode == 1 then
            OnlineLight.Transparency = 1
            if OfflineLight.Transparency == 0.5 then
                OfflineLight.Transparency = 0
            else
                OfflineLight.Transparency = 0.5
            end
        elseif Mode == 2 then
            OfflineLight.Transparency = 1
            if OnlineLight.Transparency == 0.5 then
                OnlineLight.Transparency = 0
            else
                OnlineLight.Transparency = 0.5
            end
        end
    end
end)

Spawn(function()
    while wait() do
        for _,Player in pairs(game.Players:GetPlayers()) do
            if Player.Character and Player.Character:FindFirstChild("Torso") then
                if (Player.Character.Torso.Position - Detector.Position).Magnitude <= 7 then
                    if Mode == 2 then
                        Electricity.Humming.Volume = 1
                        Electricity.Power:Play()
                        wait(0.45)
                        script.Parent.MiddleStop.CanCollide = true
                        script.Parent.Stop1.CanCollide = true
                        script.Parent.Stop2.CanCollide = true
                        Electricity.Zap:Play()
                        if Player.Character and Player.Character:FindFirstChild("Torso") then
                            if (Player.Character.Torso.Position - Detector.Position).Magnitude <= 7 then
                                Player.Character.Humanoid.Health = 0
                        script.Parent.MiddleStop.CanCollide = false
                        script.Parent.Stop1.CanCollide = false
                        script.Parent.Stop2.CanCollide = false
                            end
                        end
                        script.Parent.MiddleStop.CanCollide = false
                        script.Parent.Stop1.CanCollide = false
                        script.Parent.Stop2.CanCollide = false
                        Main.Left.Material = "Neon"
                        Main.Right.Material = "Neon"
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 1
                        Electricity.Decal1b.Transparency = 1
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 1
                        Electricity.Decal1b.Transparency = 1
                        Electricity.Decal2a.Transparency = 1
                        Electricity.Decal2b.Transparency = 1
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 1
                        Electricity.Decal1b.Transparency = 1
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 1
                        Electricity.Decal1b.Transparency = 1
                        Electricity.Decal2a.Transparency = 1
                        Electricity.Decal2b.Transparency = 1
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 1
                        Electricity.Decal1b.Transparency = 1
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 1
                        Electricity.Decal1b.Transparency = 1
                        Electricity.Decal2a.Transparency = 1
                        Electricity.Decal2b.Transparency = 1
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 1
                        Electricity.Decal1b.Transparency = 1
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 1
                        Electricity.Decal1b.Transparency = 1
                        Electricity.Decal2a.Transparency = 1
                        Electricity.Decal2b.Transparency = 1
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 1
                        Electricity.Decal1b.Transparency = 1
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 1
                        Electricity.Decal1b.Transparency = 1
                        Electricity.Decal2a.Transparency = 1
                        Electricity.Decal2b.Transparency = 1
                        Main.Left.Material = "Metal"
                        Main.Right.Material = "Metal"
                        wait(1)
                        Electricity.Humming.Volume = 0.5
                    end
                end
            end
        end
    end)

How do I fix this?

0
Line 13-43; with how you set up the code, you're missing an end. :P TheeDeathCaster 2368 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You're missing the "end)" at line 44. Add that and it should work.

Ad

Answer this question