Explanation
So I am making a keycard system for my game and I want to make it so that a proximity prompt only appears if you are holding the keycard item. I want the prompt to practicly not be in the game unless you are holding out the item. How can I do this?
This is a quick video of the door
robloxapp-20230724-1706241.wmv (1.1 MB)
Picture of the door layout
Code
local leftDoor = door.Left
local RightDoor = door.Right
local promt = door.Rpillar.Attachment.ProximityPrompt
local tweenInfo = TweenInfo.new(2)
local leftGoalOpen = {}
local leftGoalClose = {}
leftGoalOpen.CFrame = leftDoor.CFrame * CFrame.new(leftDoor.Size.X, 0, 0)
leftGoalClose.CFrame = leftDoor.CFrame
local leftTweenOpen = tS:Create(leftDoor, tweenInfo, leftGoalOpen)
local leftTweenClose = tS:Create(leftDoor, tweenInfo, leftGoalClose)
local RightGoalOpen = {}
local RightGoalClose = {}
RightGoalOpen.CFrame = RightDoor.CFrame * CFrame.new(-RightDoor.Size.X, 0, 0)
RightGoalClose.CFrame = RightDoor.CFrame
local RightTweenOpen = tS:Create(RightDoor, tweenInfo, RightGoalOpen)
local RightTweenClose = tS:Create(RightDoor, tweenInfo, RightGoalClose)
promt.Triggered:Connect(function()
if promt.ActionText == "Close" then
leftTweenClose:Play()
RightTweenClose:Play()
promt.ActionText = "Open"
else
leftTweenOpen:Play()
RightTweenOpen:Play()
promt.ActionText = "Close"
end
end)```