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

How to make a team-only click detector door?

Asked by 4 years ago

Here's my script:

local door1 = script.Parent
local door2 = script.Parent.Parent.Door2
local doorknob1 = script.Parent.Parent.DoorKnob1
local doorknob2 = script.Parent.Parent.DoorKnob2
local Opensound = script.Parent.Parent.SoundPart.Open 
local Closesound = script.Parent.Parent.SoundPart.Close

function Click()
    Opensound:Play()
    door1.Transparency = 1
    door1.CanCollide = false
    doorknob1.Transparency = 1
    doorknob1.CanCollide = false
    door2.Transparency = 0
    door2.CanCollide = true
    doorknob2.Transparency = 0
    doorknob2.CanCollide = true
    wait(1)
    Closesound:Play()
    door2.Transparency = 1
    door2.CanCollide = false
    doorknob2.Transparency = 1
    doorknob2.CanCollide = false
    door1.Transparency = 0
    door1.CanCollide = true
    doorknob1.Transparency = 0
    doorknob1.CanCollide = true
end
script.Parent.ClickDetector.MouseClick:Connect(Click)

And I have no idea how to make this door usable for teams only.

0
Make an if statement so you can check to wich team the player belongs to valledestroy 54 — 4y
0
and you can also write script.Parent.ClickDetector.MouseClick:Connect(function() valledestroy 54 — 4y
0
dont forget the end) for sure valledestroy 54 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Write this:

local door1 = script.Parent
local door2 = script.Parent.Parent.Door2
local doorknob1 = script.Parent.Parent.DoorKnob1
local doorknob2 = script.Parent.Parent.DoorKnob2
local Opensound = script.Parent.Parent.SoundPart.Open
local Closesound = script.Parent.Parent.SoundPart.Close
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player.TeamColor == BrickColor.new("Really red") then --Change to the teamcolor you want to get access
    print("You get access")
    Opensound:Play()
    door1.Transparency = 1
    door1.CanCollide = false
    doorknob1.Transparency = 1
    doorknob1.CanCollide = false
    door2.Transparency = 0
    door2.CanCollide = true
    doorknob2.Transparency = 0
    doorknob2.CanCollide = true
    wait(1)
    Closesound:Play()
    door2.Transparency = 1
    door2.CanCollide = false
    doorknob2.Transparency = 1
    doorknob2.CanCollide = false
    door1.Transparency = 0
    door1.CanCollide = true
    doorknob1.Transparency = 0
    doorknob1.CanCollide = true
else 
     print("No access for you")
end
end)

Thank me later

Ad

Answer this question