Proximity prompt Keycard Door is not working

How’s it going! I was looking at some tutorial to make a Keycard Door with Proximity prompt but apparently this doesn’t work for me…

This is the script, I don’t know if it will have any problem, the idea is that it opens with a tween effect but it doesn’t work…

local TweenService = game:GetService(‘TweenService’)
local time = 2

script.Parent.ProximityPrompt.Triggered:Connect(function(Player)
if Player:WaitForChild(‘Backpack’):FindFirstChild(‘KeyCard’) or Player.Character:FindFirstChild(‘KeyCard’) then

	script.Parent.ProximityPrompt.Enabled = false
	
	
	TweenService:Create(script.Parent.Parent.MainDoor, TweenInfo(time,Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut ), {Position = script.Parent.Parent.RotateDoor.Position, Orientation = script.Parent.Parent.RotateDoor.Orientation}):Play()
	
	wait(time + time)
	
	TweenService:Create(script.Parent.Parent.MainDoor, TweenInfo(time,Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut ), {Position = script.Parent.Parent.ReferDoor.Position, Orientation = script.Parent.Parent.ReferDoor.Orientation}):Play()
	
	wait(time)
	
	script.Parent.ProximityPrompt.Enabled = true
end

end)

Help Pls…I don’t know if the script is wrong or I made a mistake but it would help me a lot if someone helps me

Try doing this instead.

TweenService:Create(script.Parent.Parent.MainDoor, TweenInfo(time,Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut ), {CFrame = script.Parent.Parent.RotateDoor.CFrame}):Play()

and then change rotate door to refer door in the other

I tried and still not working…

Is it throwing an error in the output?

1 Like

Nope, that’s the strangest thing, it doesn’t throw me any errors

1 Like

It’s probably because its not finding the keycard in keycard tool in either the character or the backpack.
after the if Player:WaitForChild(‘Backpack’):FindFirstChild(‘KeyCard’) or Player.Character:FindFirstChild(‘KeyCard’) then statement, add a print statement.
If the print statement is printed, that means it can’t find the keycard

1 Like

Sorry if I ask this but I’m not that expert in scripting but how could I correctly add that?

Try this

local TweenService = game:GetService(‘TweenService’)
local time = 2

script.Parent.ProximityPrompt.Triggered:Connect(function(Player)
if Player:WaitForChild(‘Backpack’):FindFirstChild(‘KeyCard’) or Player.Character:FindFirstChild(‘KeyCard’) then
    print("Found KeyCard!") -- this will print if it finds the keycard
	script.Parent.ProximityPrompt.Enabled = false
	
	
	TweenService:Create(script.Parent.Parent.MainDoor, TweenInfo(time,Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut ), {Position = script.Parent.Parent.RotateDoor.Position, Orientation = script.Parent.Parent.RotateDoor.Orientation}):Play()
	
	wait(time + time)
	
	TweenService:Create(script.Parent.Parent.MainDoor, TweenInfo(time,Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut ), {Position = script.Parent.Parent.ReferDoor.Position, Orientation = script.Parent.Parent.ReferDoor.Orientation}):Play()
	
	wait(time)
	
	script.Parent.ProximityPrompt.Enabled = true
end

Well…it recognizes the keycard but the door doesn’t open

oh, I just noticed!
instead of just TweenInfo()
you need to use TweenInfo.new()

It still doesn’t work… but thank you anyway :slight_smile:

I made a blank baseplate and set up all the parts as their referred to in the script, and it works.

Here’s the script I used

local TweenService = game:GetService('TweenService')
local time = 2

script.Parent.ProximityPrompt.Triggered:Connect(function(Player)
	if Player:WaitForChild('Backpack'):FindFirstChild('KeyCard') or Player.Character:FindFirstChild('KeyCard') then
		print("Found KeyCard!") -- this will print if it finds the keycard
		script.Parent.ProximityPrompt.Enabled = false


		TweenService:Create(script.Parent.Parent.MainDoor, TweenInfo.new(time,Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut ), {Position = script.Parent.Parent.RotateDoor.Position, Orientation = script.Parent.Parent.RotateDoor.Orientation}):Play()

		wait(time + time)

		TweenService:Create(script.Parent.Parent.MainDoor, TweenInfo.new(time,Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut ), {Position = script.Parent.Parent.ReferDoor.Position, Orientation = script.Parent.Parent.ReferDoor.Orientation}):Play()

		wait(time)

		script.Parent.ProximityPrompt.Enabled = true
	end
end)

And here’s my explorer

Screenshot 2022-12-03 182940

2 Likes

WOW amazing… But I have a question, the part that is where it goes, since the main door is the refer door, is where the door will move, but what is the ‘‘part’’?

Oh, I just put the proximity prompt in a random part.
It really doesn’t matter because as long as the script is in the same part as the proximity prompt, it will function.

1 Like

LETS GOOOO BROOOO THX SO MUCH IS WORKING NOW :smiley:

1 Like

Hey, something else to leave this issue alone, I was testing and there would be a way to make the door detect the item that the player has equipped, not his entire backpack

Just change this line

if Player:WaitForChild('Backpack'):FindFirstChild('KeyCard') or Player.Character:FindFirstChild('KeyCard') then

To this

if Player.Character:FinidFirstChild('KeyCard') then
1 Like

Thanks so much I would ask one more question but it is somewhat complicated anyway thank you very much you have helped me a lot :smiley:

1 Like

I created my own complex system similar to what you’re attempting to do.

If you have additional questions, I can try to help. You can contact me at (jayden#0577)

1 Like

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