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:

door1 = script.Parent
Defender = BrickColor.new("Bright green")
Raider = BrickColor.new("Bright red")

function door(plr)
    if plr.TeamColor == Defender then
        door1.Transparency = 1
        door1.CanCollide = false
        wait(2)
        door1.Transparency = 0.5
        door1.CanCollide = true
    elseif plr.TeamColor == Raider then
        door1.Transparency = 0.5
        door1.CanCollide = true
        r = plr.Name
        m = Instance.new("Hint")
        m.Parent = game.Workspace
        m.Text = r.."Is Trying To Enter The Defender Spawn!"
        wait(5)
        m:remove()
    end
end

door1.Touched:connect(door)

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.




function debounce(f) local d = false return function(...) if not d then d = true f(...) -- d = false end end end --[[I have no idea how to use that function but I would do,]] door1.Touched:connect((debounce(function(plr) if plr.Parent:findFirstChild("Humanoid") and game.Players:findFirstChild(plr.Parent.Name) then i = game.Players:findFirstChild(plr.Parent.Name) if i.TeamColor == Defender then door1.Transparency = 1 door1.CanCollide = false wait(2) door1.Transparency = 0.5 door1.CanCollide = true elseif i.TeamColor == Raider then door1.Transparency = 0.5 door1.CanCollide = true r = i.Name m = Instance.new("Hint") m.Parent = game.Workspace m.Text = r.."Is Trying To Enter The Defender Spawn!" wait(5) m:remove() end end end end))
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