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)
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
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)
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.
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)