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

Certain user only door not working, can someone look at the script?

Asked by
Zeluxis 100
6 years ago

I've tried making a door which only lets certain people through it, this is what I have so far.

script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local Character = hit.Parent
        local Player = game.Players:GetPlayerFromCharacter(Character)
        if Player.Name == {"Zeluxis","CallumStoneUK","MattBaker179"} then
            script.Parent.CanCollide = false
            wait(1)
            script.Parent.CanCollide = true
        end
    end
end)

For some reason it wont work at all, and I'm really confused.

Thanks.

0
You would be better off using collision groups, https://blog.roblox.com/2017/05/introducing-collision-groups/ User#5423 17 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You didn't specify what part of the table you want to access. You need to specify every variable specifically.

local playersallowed = {"Zeluxis","CallumStoneUK","MattBaker179"}
local allowed = false
for i, v in pairs(playersallowed) do
    if Player.Name == v then
        allowed = true
        break
    end
end

--have a checker if allowed is true.
Ad

Answer this question