Item only proximity promt

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
image

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)```
1 Like

Toggle the enabled of the ProximityPrompt depending on whether the tool is equipped or not.

tool.Equipped:Connect(function()
    prompt.Enabled = true
end)

tool.Unequipped:Connect(function()
    prompt.Enabled = false
end)

Hi, yeah I will try that but is there an easy way for it to enable every prompt for every door in the game?

Use tags; essentially for every proximity prompt for a door in your game, tag them as “DoorPrompt” and then inside the tool.Equipped and tool.Unequipped just loop over every tagged prompt and set its Enabled prop accordingly

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