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

Make a door that more than one team can walk through?

Asked by 5 years ago
Edited 5 years ago

I've been trying several methods but they seem not to be working, the door only opens for the Maroon team, and not the Bright red team. Whatever is listed first will open the door for that specific team. But in this case, I want more than one team to walk through the door instead of just one team. Responses are appreciated. [The AntiHack and fancy stuff is not necessary, a simple script would do just fine too.]

TeamColor="Maroon" --the team color allowed though
Time=2   -- time to keep door opened
AntiHack=1 --This is the mode it will do to intruders who touch the door   0= mostly nothing if they sneak, 1= pushes em back and sits em ^_^, 2=Kills em on touch....
ColorDoor=false --whether it colors the door the team color you disignated
----------------------------------------code------------------------------------------------------------------------------
Color=BrickColor.new(TeamColor)
on=false
s=script.Parent
ss=script.Parent:clone()
s.BrickColor=Color
function Check(hit) if on then return end
if hit==nil then return end
local player=game.Players:FindFirstChild(hit.Parent.Name)
if player==nil then return end
on=true
    if player.TeamColor==Color then
    s.Transparency=0
    s.CanCollide=false
    wait(Time)
    s.Transparency=ss.Transparency
    s.CanCollide=true
    else
    local h=player.Character:FindFirstChild("Humanoid")
    local t=player.Character:FindFirstChild("Torso")
    if t==nil or h==nil then s.CanCollide=true s.Transparency=ss.Transparency on=false return end
    if AntiHack==1 then
    h.Sit=true
    t.Velocity=t.CFrame:inverse().lookVector*80
    elseif AntiHack==2 then
    h.Health=0
    elseif AntiHack==0 then
    else hit.Parent=nil
    end
    end
on=false
end

s.Touched:connect(Check)


0
I posted a answer more Easy to do, you can modify if you like. i explained all and its easy yHasteeD 1819 — 5y

2 answers

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

My idea.

Alright so I think I know what you can do as if I remember correctly and correct me if i'm wrong but you can add more than one value to a NameValue such as TeamColor so I'm taking a guess at this to see if this works..

What I did

All I really did was just add "Teal" into the value of TeamColor, now of course you'll have to change that to a color of what you have. If that doesn't work, try changing the or to an ,

Here you go, my tiny extra fix.

TeamColor = "Maroon" or "Teal" --the team color allowed though
Time = 2   -- time to keep door opened
AntiHack = 1 --This is the mode it will do to intruders who touch the door   0= mostly nothing if they sneak, 1= pushes em back and sits em ^_^, 2=Kills em on touch....
ColorDoor = false --whether it colors the door the team color you disignated
----------------------------------------code------------------------------------------------------------------------------
Color=BrickColor.new(TeamColor)
on=false
s=script.Parent
ss=script.Parent:clone()
s.BrickColor=Color
function Check(hit) if on then return end
if hit==nil then return end
local player=game.Players:FindFirstChild(hit.Parent.Name)
if player==nil then return end
on=true
    if player.TeamColor==Color then
    s.Transparency=0
    s.CanCollide=false
    wait(Time)
    s.Transparency=ss.Transparency
    s.CanCollide=true
    else
    local h=player.Character:FindFirstChild("Humanoid")
    local t=player.Character:FindFirstChild("Torso")
    if t==nil or h==nil then s.CanCollide=true s.Transparency=ss.Transparency on=false return end
    if AntiHack==1 then
    h.Sit=true
    t.Velocity=t.CFrame:inverse().lookVector*80
    elseif AntiHack==2 then
    h.Health=0
    elseif AntiHack==0 then
    else hit.Parent=nil
    end
    end
on=false
end

s.Touched:connect(Check)


Ad
Log in to vote
0
Answered by
yHasteeD 1819 Moderation Voter
5 years ago

Well, you can make it checking the name in a dictionary tables, like a whitelist:

local List = {
    ["Maroon"] = true;
    -- ...
}

Then you need to check if List[tostring(Player.TeamColor)] then on the Touch Event, if its true, then you can make your functional, if not, kill the player. Example:

--> Services
local Players = game:GetService("Players")

--> Variables
local Part = script.Parent
local Debounces = {} --> Make a Player Debounce, for the player not touch soo much times in like 1 second.
local List = {
    ["Maroon"] = true;
}

Part.Touched:Connect(function(Hit)
    local Humanoid = Hit.Parent:FindFirstChild("Humanoid") --> Try to find Humanoid
    local Player = Humanoid and Players:GetPlayerFromCharacter(Hit.Parent) --> If Humanoid exists get player, else nil.
    if  Player then --> Check if the player exists
        if List[Player.TeamColor] then
            if Debounces[Player.Name] then return end --> If find the player Debounce then return.
            Debounces[Player.Name] = true --> Set debounce to true.
            --> Player allowed
            Part.Transparency = 0.5
            Part.CanCollide = false
            delay(1, function() --> After 1 second, close the door
                Part.Transparency = 0
                Part.CanCollide = true
                --> Here set Debounce to false
                Debounces[Player.Name] = false
            end)
        else
            --> Here, just do the kill.
            Humanoid.Parent:BreakJoints() --> Instant kill...
        end
    end
end)

Hope it helped!

Answer this question