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 )
script:
local door = game.Workspace.BlueDoor.Door
local player = script.Parent.Parent.Parent.Parent
local tool = script.Parent.Parent
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.
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.
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)
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)