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.]
01 | TeamColor = "Maroon" --the team color allowed though |
02 | Time = 2 -- time to keep door opened |
03 | 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.... |
04 | ColorDoor = false --whether it colors the door the team color you disignated |
05 | ----------------------------------------code------------------------------------------------------------------------------ |
06 | Color = BrickColor.new(TeamColor) |
07 | on = false |
08 | s = script.Parent |
09 | ss = script.Parent:clone() |
10 | s.BrickColor = Color |
11 | function Check(hit) if on then return end |
12 | if hit = = nil then return end |
13 | local player = game.Players:FindFirstChild(hit.Parent.Name) |
14 | if player = = nil then return end |
15 | on = true |
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.
01 | TeamColor = "Maroon" or "Teal" --the team color allowed though |
02 | Time = 2 -- time to keep door opened |
03 | 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.... |
04 | ColorDoor = false --whether it colors the door the team color you disignated |
05 | ----------------------------------------code------------------------------------------------------------------------------ |
06 | Color = BrickColor.new(TeamColor) |
07 | on = false |
08 | s = script.Parent |
09 | ss = script.Parent:clone() |
10 | s.BrickColor = Color |
11 | function Check(hit) if on then return end |
12 | if hit = = nil then return end |
13 | local player = game.Players:FindFirstChild(hit.Parent.Name) |
14 | if player = = nil then return end |
15 | on = true |
Well, you can make it checking the name in a dictionary tables, like a whitelist:
1 | local List = { |
2 | [ "Maroon" ] = true ; |
3 | -- ... |
4 | } |
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:
01 | --> Services |
02 | local Players = game:GetService( "Players" ) |
03 |
04 | --> Variables |
05 | local Part = script.Parent |
06 | local Debounces = { } --> Make a Player Debounce, for the player not touch soo much times in like 1 second. |
07 | local List = { |
08 | [ "Maroon" ] = true ; |
09 | } |
10 |
11 | Part.Touched:Connect( function (Hit) |
12 | local Humanoid = Hit.Parent:FindFirstChild( "Humanoid" ) --> Try to find Humanoid |
13 | local Player = Humanoid and Players:GetPlayerFromCharacter(Hit.Parent) --> If Humanoid exists get player, else nil. |
14 | if Player then --> Check if the player exists |
15 | if List [ Player.TeamColor ] then |