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

How do I fix my restricted doors?

My restricted door worked fine but now it doesn't I've tried as much as I can and it's still broken, here's the code. Please help.

local door = script.Parent
 
function open()
	-- This function will open the door.
	door.CanCollide = false -- Make players able to walk through the door.
 
	for transparency = 0, 1, .1 do
		door.Transparency = transparency
		wait(.1)
	end
end
 
function close()
	-- This function will close the door.
	for transparency = 1, 0, -.1 do
		door.Transparency = transparency
		wait(.1)
	end
 
	door.CanCollide = true -- Make players unable to walk through the door.
end
 
-- This function returns the player a certain part belongs to.
function get_player(part)
	--iterate over each player
	for _, player in ipairs(game.Players:GetPlayers()) do
		--if the part is within the player's character 
		if part:IsDescendantOf(player.Character) then
			--return the player
			return player
		end
	end
end
 
 
door.Touched:connect(function(part)
	-- If it isn't a character that touched the door, then we ignore it.
	local player = get_player(part)
	if not player then return end
 
	local allow = (
		player.Name == "TheRabster1428" or
		player.Name == "Whirlpooled" or 
		player.Name == "TylerTiger88" or 
		player.Name == "TylerTiger88V2" or
		player.Name == "lXMysteryXl" or
		player.Name == "AncientDinoDan"
		player.Name == "djnightkiller" or
		player.Name == "danknoscoper12" or
		player.Name == "JuntheDoge" or
		player.Name == "peopledumb" or
		player.Name == "iliketranezz" or
		player.Name == "Quoonisbest" or
		player.Name == "willywaffle99"
	)
	if allow then
		open()
		delay(4, close)
	end
end)

1 comment

0

on line 41, instead of writing or after every name, you could put a ";" i think that would work

2 answers

I tried running this on Roblox and it looks like on line 47 you are missing an or at the end, which is causing your problem, try switching line 47 from player.Name == "AncientDinoDan" to player.Name == "AncientDinoDan" or

1 comment

0

Thank you so much! It works now!

As Aresko said, you are missing an or on line 47. I would also recommend adding a Debounce to your door script. Basically, the script will run for each of your limbs that touches the door. If you add a debounce, then it will only run once.

http://wiki.roblox.com/index.php?title=Debounce

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