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

How do you allow people through Door restrictions?

Asked by 8 years ago

I tried different codes GetChildren, GetPlayers, IsInGroup, game.Players.LocalPlayers and it just wouldn't allow anyone to go through the door. I just want TeamColor "Really Blue" also known as Team "ct" to get through the door

local leaderboard = script.Parent.Parent:WaitForChild('leaderboard')
local door = script.Parent

function open()
    door.CanCollide = false 
    for transparency = 0, 1, .1 do
        door.Transparency = transparency
        wait(.1)
    end
end

function close()
    for transparency = 1, 0, -.1 do
        door.Transparency = transparency
        wait(.1)
    end
    door.CanCollide = true
end


function get_player(part)
    for _, player in ipairs(game.Players:GetPlayers()) do
        if part:IsDescendantOf(player.Character) then
            return player
        end
    end
end


door.Touched:connect(function(part)
    local player = get_player(part)
    if not player then return end

    local allow = (
        game.Players:GetChildren().TeamColor == 'Really blue' --THIS LINE IS KILLING ME
    )
    if allow then
        open()
        delay(4, close)
    elseif not allow then
        game.Players.LocalPlayer:LoadCharacter()
    end
end)

Oh and if you are going to reply don't reply to me about "IsInGroup".

0
Also it just loads the character... No errors found hardhitsniper 30 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

This is what's wrong:

game.Players:GetChildren().TeamColor == 'Really blue'

It is wrong because:

1. You did not specify which child of game.Players:GetChildren() to index.

2. Team Color values are not strings, they are BrickColor.new("Color name")

This is a different, simpler version of your function, less fancy, but just as effective:

door.Touched:connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        if player.TeamColor == BrickColor.new("Really blue") then
            open()
            delay(4,close)
        end
    end
end)
Ad

Answer this question