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

how do i make a door that only lets one team through and blocks the other team?

Asked by
0uh0k 0
3 years ago
Edited by JesseSong 3 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).
--something went wrong with this script, help me fix it


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

function door(plr)
    if plr.TeamColor == Defender then
        door1.Transparency = 1
        door1.CanCollide = false
        wait(2)
        door1.Transparency = 1
        door1.CanCollide = true
    elseif plr.TeamColor == Raider then
        door1.Transparency = 1
        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)

1 answer

Log in to vote
0
Answered by 3 years ago

door1.Touched:Connect(door) <-- Suggestion, use Connect with a capital C

function door(plr)

the so called plr here isn't actually the player, its whichever part that touches Door1. To get the actual "plr", its just game.Players:GetPlayerFromCharacter(plr.Parent). Only then, the script can detect the TeamColor of the player

Ad

Answer this question