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

Help! TouchEnded and group only? Tesla gate (SCP)?

Asked by 6 years ago

How would I make the tesla gate disable when a player removes his/hers body from the button. (They Have to stay on it to work) and also to make this open only if they are in the group.(If not in the group the tesla gate don't work(ALSO NEEDS SPECIFIC RANK TO WORK!!)) (Touch ended on the line 5-7)(And I need to make the script only work for the person in the group and its specific rank) I did start off the script here:

print("Tesla gate loaded(Touch)")

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
groupid = 1
rank = 1
local Debounce = false


Button.Touched:connect(function(Player)
    if Player~= nil and Player:GetRankInGroup(groupid) >= rank then
        else script.Disabled = true
    end
            if Button.TouchEnded then
        -- Right here is where I need the script
    end
    if Debounce then return end
    Debounce = true
        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
        script.Parent.EmitterTest.g.ParticleEmitter.Enabled = true
        script.Parent.EmitterTest.h.ParticleEmitter.Enabled = true
        script.Parent.EmitterTest.i.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
        script.Parent.EmitterTest.g.ParticleEmitter.Enabled = false
        script.Parent.EmitterTest.h.ParticleEmitter.Enabled = false
        script.Parent.EmitterTest.i.ParticleEmitter.Enabled = false
        Electricity.Humming:Stop()
        Mode = 1
    end
    wait(0.4)
    Debounce = false
end
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 = 0
                        Electricity.Decal1b.Transparency = 0
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        wait(0.01)
                        Electricity.Decal1a.Transparency = 0
                        Electricity.Decal1b.Transparency = 0
                        Electricity.Decal2a.Transparency = 0
                        Electricity.Decal2b.Transparency = 0
                        Main.Left.Material = "Metal"
                        Main.Right.Material = "Metal"
                        wait(1)
                        Electricity.Humming.Volume = 0.5
                    end
                end
            end
        end
    end
end)

0
Don't put it into an if statement. Put it by itself `Button.TouchEnded:Connect(functiion(part) --code here end)` MooMooThalahlah 421 — 6y

Answer this question