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
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
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
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)
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.
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