Pass through door script help

Hi,

I tried making my own script where if you touch a door it lets you go through it.
I can’t seem to get this to work.

local door = script.Parent

door.CanCollide = true

Touched.game.workspace.door:Connect(function(plr)
	user = plr.parent
	human = plr:FindFirstChild("Humanoid")
	if human then
		door.Transparency = 0.5
		door.CanCollide = false
	end

end)

There is a couple mistakes in this script!

local door = script.Parent

door.CanCollide = true

door.Touched:Connect(function(plr)
	human = plr.Parent:FindFirstChild("Humanoid")
	if human then
		door.Transparency = 0.5
		door.CanCollide = false
	end

end)

You can just use plr since that is already a variable.
Also, when trying to get the character, make sure you get the parent of the variable “plr”, since this is referring to the object that is being touched

fixed the door.Touched line too.

Ive removed the user variable. I can’t find the other issue.

local door = script.Parent

door.CanCollide = true

Touched.game.workspace.door:Connect(function(plr)
	
	human = plr.parent:FindFirstChild("Humanoid")
	if human then
		door.Transparency = 0.5
		door.CanCollide = false
	end

end)

local door = script.Parent

door.CanCollide = true

door.Touched:Connect(function(plr)
	
	human = plr.Parent:FindFirstChild("Humanoid")
	if human then
		door.Transparency = 0.5
		door.CanCollide = false
	end

end)

make sure the p in “Parent” is capatalized.

Hey it works thanks!

How could I make it a bit more quick to let me pass through. There like a half second delay before it lets me go.

hello im new here can you say whats your problem I can help

Unfortunately not, I am very sorry.

You can perhaps add a transparent part that is scaled such that it surrounds the door, and its height higher than the Player could jump.

Doing this, it helps detect the Player faster when they approach near the door. This would mean that the door would open at a distance before the Player approaches the door, though.

Your script can look something like this (would stick to @dudezwithattitudez ’s script so it’s easier to edit) :

local door = script.Parent
local detector = game.Workspace.DetecterPart

detecter.Touched:Connect(funtion(plr)
   human = plr.Parent:FindFirstChild(“Humanoid”)
   if human then
     door.Transparency = 0.5
		door.CanCollide = false
	end
end)

This is pretty much a get around for detecting the Player faster, but nothing special. :slightly_smiling_face:

1 Like
local door = script.Parent

door.CanCollide = true

door.Touched:Connect(function(plr)
	
	human = plr.Parent:FindFirstChild("Humanoid")
	if human then
		door.Transparency = 0.5
		door.CanCollide = false
                task.wait(2)
                door.Transparency = 0
		door.CanCollide = true
	end

end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.