Door System that Disappears for the player who unlocked it

I am trying to make a door that you need a key for it with proximity prompt. But I want it to do one specific thing so when the player unlocks it I want to make it disappear only for the player who has unlocked it.

The issue is that I can’t make the script to work with the proximity prompt cause when I try to make it it’s unlock the door for every player.

I have been trying to search on internet to respond to my question, but I didn’t find anything that answered my question.

The script that I am using right now only make that you can get trough the door if you have the key equipped.

here is the script that I am using right now and I would want to make it work with proximity prompt but I can’t figure it how.
(the script is in the key cause i also don’t know how to make it work for the door so if you could help me with that that would be generous :slight_smile: )
script:
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.