I think I fixed another issue with my script, but now the prox on the door isnt working in my script. I tried changing to touching and etc. no use. The door opens per one person and if you dont have the key then it wont but now it wont open for no one.
here is my script. i think its something with the character…
You aren’t using the ProximityPrompt in the door that you’ve cloned. Instead you’re using the ProximityPrompt in the door in ReplicatedStorage.
The way you are checking if the “GreenKey” is under the players character will error if it isn’t there.
You are also assuming the players character exists when the prompt is triggered. In most cases the players character should exists but in some rarer cases the players character may not exists. It is good practice to check for the players characrter.
Try this code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local door = ReplicatedStorage.Door10:Clone()
local prox = door.Prox
door.Parent = workspace
prox.Triggered:Connect(function(player)
local character = player.Character
-- Makes sure the players character exists
if character ~= nil and character.Parent == workspace then
-- Checks if the character has a green key
if character:FindFirstChild("GreenKey") then
door.Transparency = 0.5
door.CanCollide = false
-- Better alternative to using wait(n)
task.wait(1)
door.Transparency = 0
door.CanCollide = true
end
end
end)