Door System that Disappears for the player who unlocked it

I’m working on a door that players can unlock with a proximity prompt, but I want it to have a specific functionality. When a player unlocks the door, I want it to disappear only for that player, rather than for everyone.

The problem is that, currently, my script makes the door unlock for all players once any one player unlocks it. I’ve been searching online for a solution, but I haven’t found an answer to my question.

Right now, my script only checks if the player has the key equipped to go through the door. I’d like to make it work with a proximity prompt but can’t figure out how to implement this.

The script is currently attached to the key because I also haven’t figured out how to link it directly to the door. If you could help me with that, it would be a huge help.

Here’s the script I’m using right now:

local door = game.Workspace.BlueDoor.Door
local player = script.Parent.Parent.Parent.Parent
local tool = script.Parent.Parent

function equip()
door.CanCollide = false
end

function unequip()
door.CanCollide = true
end

tool.Equipped:Connect(equip)
tool.Unequipped:Connect(unequip)

3 Likes

Your Keycard Has To Be Hit Right?

Well If Its So

script.Parent.Touched:Connect(function(hit)
	if hit.Parent.Name == "Keycard" then -- your tool name
		script.Parent.Transparency = 1
		script.Parent.CanCollide = false
        wait(1)
		script.Parent.Transparency = 0
		script.Parent.CanCollide = true
	end
end)

You Have Put Script To Part. Make Sure Is A ServerScript.

2 Likes

Well yes but I would want to make it like with the proximity prompt like that you need to e to unlock the door but I also want to make it for only the player that has unlocked it not the other player.

1 Like

I made a eprompt that if player equip the keycard it will open

script

script.Parent.Triggered:Connect(function(player)
	if player.Character.Keycard then
		script.Parent.Parent.Transparency = 1
		script.Parent.Parent.CanCollide = false
		wait(1)
		script.Parent.Parent.Transparency = 0
		script.Parent.Parent.CanCollide = true
	else
		print("No Keycard Founded")
	end
end)
3 Likes

Oh thank you just an question were do I put the script in the door or in the proximity prompt?

1 Like

serverscript on proximityprompt

1 Like

ok i will try that right away I will tell you if there is any issue

1 Like

If you want it to disappear for one player and stay gone you would need to use local scripts and remote events.

create a RemoteEvent inside of replicated storage

for the a script inside of the proximityprompt you could do:

local prompt = script.Parent
local doorModel = --What ever the door you want to be gone
local RemoteEvent = game.ReplicatedStorage.OpenDoorRemoteEvent

prompt.Triggered:Connect(function(player)
	if player.Backpack:FindFirstChild("Keycard") then
		RemoteEvent:FireClient(player, doorModel)
	end
end)

then in a local script in starterplayerscripts you could do

local RemoteEvent = game.ReplicatedStorage.OpenDoorRemoteEvent
RemoteEvent.OnClientEvent:Connect(function(doorModel)
	doorModel:Destroy()
end)

hopefully this should work.

2 Likes

oh thank you I will also try this

for the script it’s don’t seem to work for the doorModel it’s seem to put me an error in the script

1 Like

the door model should be to the part of the door model so most likely if you have the prompt inside of the door model

local doorModel = prompt.Parent
1 Like

ok I will try that right away Thank you!

1 Like

Well the proximity prompt is inside the part which is called Door. grouped in An model called Blue door

1 Like

you would then use the prompt.Parent example i gave you then

2 Likes

Ok it’s actually working when the key is not equipped how could do it so it’s also work when the key is equipped

1 Like

you could just change it in the server script to:

local prompt = script.Parent
local doorModel = --What ever the door you want to be gone
local RemoteEvent = game.ReplicatedStorage.OpenDoorRemoteEvent

prompt.Triggered:Connect(function(player)
	if player.Backpack:FindFirstChild("Keycard") or player.Character:FindFirstChild("Keycard") then
		RemoteEvent:FireClient(player, doorModel)
	end
end)
1 Like

ok I will try that I will tell you if there is any issue

Thank you for your help I appreciate it . It’s now working has I wanted :slight_smile:

1 Like

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