Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

1 comment

0

You would be better off using collision groups, https://blog.roblox.com/2017/05/introducing-collision-groups/

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.