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

How do I make a team-only door?

Asked by 10 years ago

I am trying to create a door that only lets one team through and blocks the other team and makes a hint when the wrong team member is trying to get through it.

This is what I have so far:

01door1 = script.Parent
02Defender = BrickColor.new("Bright green")
03Raider = BrickColor.new("Bright red")
04 
05function door(plr)
06    if plr.TeamColor == Defender then
07        door1.Transparency = 1
08        door1.CanCollide = false
09        wait(2)
10        door1.Transparency = 0.5
11        door1.CanCollide = true
12    elseif plr.TeamColor == Raider then
13        door1.Transparency = 0.5
14        door1.CanCollide = true
15        r = plr.Name
View all 24 lines...

I am guessing that "plr" refers to the door instead of the player who touched the door. How do I refer to the player who hit the door in the function?

0
didnt work 0uh0k 0 — 3y

2 answers

Log in to vote
1
Answered by 10 years ago

no plr refers to the player that goes through dooor. Its a parameter for the functioon determining if a player can pass through the door.....

0
Okay thanks. PureDefiance 20 — 10y
0
I kind of fixed that in my answer cx Adryin 120 — 10y
Ad
Log in to vote
1
Answered by
Adryin 120
10 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
01function debounce(f)
02    local d = false  
03    return function(...)   
04        if not d then
05            d = true
06 
07            f(...)          --
08            d = false
09        end
10    end
11end
12 
13--[[I have no idea how to use that function but I would do,]]
14door1.Touched:connect((debounce(function(plr)
15if plr.Parent:findFirstChild("Humanoid") and game.Players:findFirstChild(plr.Parent.Name) then
View all 36 lines...
0
Er I tried that and it is still not working. PureDefiance 20 — 10y
0
Oh I know the problem, I'll edit it. Adryin 120 — 10y
0
There I edited the answer. Adryin 120 — 10y

Answer this question