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

How do I make this force field allow only certain players through?

Asked by 5 years ago
Edited 5 years ago

I don't know how to explain this very well, but it is a door that when a non-group member or rank 1 group member passes through it'll solidify and kill anyone who touches it while setting an alarm off, but if you are a group member and you have the rank 2+ then it'll let you through without anything happening. The door part works, but the sound will only play once if you are in the group and have a rank of 2+.

game.Players.PlayerAdded:connect(function(Player)
local Rank = Player:GetRankInGroup(4087912)
local Enter = script.Parent.Enter
local shield = script.Parent
local debounce = false
local kill = shield.Kill
local flash = script.Parent.Flash

shield.Touched:Connect(function()
    if debounce == false then 
            debounce = true
    Enter:Play()
if Rank == 0 or Rank == 1 then  
    workspace.AlarmSound:Play()
    wait(.6)
    flash.Disabled = true
    kill.Disabled = false
    shield.CanCollide = true
    shield.Transparency = .5
    wait(.005)
    shield.Transparency = .4
    wait(.005)
    shield.Transparency = .3
    wait(.005)
    shield.Transparency = .2
    wait(.005)
    shield.Transparency = .1
    wait(.005)
    shield.Transparency = 0
    wait(35)
    kill.Disabled = true
    flash.Disabled = false
    workspace.AlarmSound:Stop()
    debounce = false
end
end
end)
end)

Thanks if you can help.

0
Sorry for not explaining what the "Sound" is, it's supposed to be an effect for when you walk through. CaptainAlien132 225 — 5y
0
After all these times, you’re not using Connect. It’s Connect not connect! User#19524 175 — 5y
0
Oh I use an old script I made it has connect so I don't change it, plus it works either way so I don't see the big deal. If it gets deprecated I can just go in and fix it. CaptainAlien132 225 — 5y
0
I also found the problem I put end in the wrong spot CaptainAlien132 225 — 5y
0
@CaptainAlien132, you could've simplified some of the code with a number for loop saSlol2436 716 — 5y

Answer this question