I am trying to make a custom proximity prompt system with a custom bilboard for the prompt,
the code should check every time it will show a gui if a global value is true or false,
if true it should show so i can disable all prompts when for example a player gets into a vehicle.
However,
Once the value is disabled all prompts don’t show as excpected except you can still trigger other prompt whilst in the vehicle for some reason.
I have been debugging for about an hour and searching on the DevForum for anyone that might have the same problem as me.
I have not found anything.
local proximityPromptService = game:GetService("ProximityPromptService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local userInputService = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local players = game:GetService("Players")
local localPlayer = players.LocalPlayer
local components = replicatedStorage:FindFirstChild("Components")
local objects = components:FindFirstChild("Objects")
local folder = objects:FindFirstChild("CustomPrompt")
local playerGui = localPlayer:FindFirstChild("PlayerGui")
local customPrompt = folder:FindFirstChild("Prompt")
local GamepadButtonImage = {
	[Enum.KeyCode.ButtonX] = "rbxasset://textures/ui/Controls/xboxX.png",
	[Enum.KeyCode.ButtonY] = "rbxasset://textures/ui/Controls/xboxY.png",
	[Enum.KeyCode.ButtonA] = "rbxasset://textures/ui/Controls/xboxA.png",
	[Enum.KeyCode.ButtonB] = "rbxasset://textures/ui/Controls/xboxB.png",
	[Enum.KeyCode.DPadLeft] = "rbxasset://textures/ui/Controls/dpadLeft.png",
	[Enum.KeyCode.DPadRight] = "rbxasset://textures/ui/Controls/dpadRight.png",
	[Enum.KeyCode.DPadUp] = "rbxasset://textures/ui/Controls/dpadUp.png",
	[Enum.KeyCode.DPadDown] = "rbxasset://textures/ui/Controls/dpadDown.png",
	[Enum.KeyCode.ButtonSelect] = "rbxasset://textures/ui/Controls/xboxView.png",
	[Enum.KeyCode.ButtonStart] = "rbxasset://textures/ui/Controls/xboxmenu.png",
	[Enum.KeyCode.ButtonL1] = "rbxasset://textures/ui/Controls/xboxLB.png",
	[Enum.KeyCode.ButtonR1] = "rbxasset://textures/ui/Controls/xboxRB.png",
	[Enum.KeyCode.ButtonL2] = "rbxasset://textures/ui/Controls/xboxLT.png",
	[Enum.KeyCode.ButtonR2] = "rbxasset://textures/ui/Controls/xboxRT.png",
	[Enum.KeyCode.ButtonL3] = "rbxasset://textures/ui/Controls/xboxLS.png",
	[Enum.KeyCode.ButtonR3] = "rbxasset://textures/ui/Controls/xboxRS.png",
	[Enum.KeyCode.Thumbstick1] = "rbxasset://textures/ui/Controls/xboxLSDirectional.png",
	[Enum.KeyCode.Thumbstick2] = "rbxasset://textures/ui/Controls/xboxRSDirectional.png",
}
local KeyboardButtonImage = {
	[Enum.KeyCode.Backspace] = "rbxasset://textures/ui/Controls/backspace.png",
	[Enum.KeyCode.Return] = "rbxasset://textures/ui/Controls/return.png",
	[Enum.KeyCode.LeftShift] = "rbxasset://textures/ui/Controls/shift.png",
	[Enum.KeyCode.RightShift] = "rbxasset://textures/ui/Controls/shift.png",
	[Enum.KeyCode.Tab] = "rbxasset://textures/ui/Controls/tab.png",
}
local KeyboardButtonIconMapping = {
	["'"] = "rbxasset://textures/ui/Controls/apostrophe.png",
	[","] = "rbxasset://textures/ui/Controls/comma.png",
	["`"] = "rbxasset://textures/ui/Controls/graveaccent.png",
	["."] = "rbxasset://textures/ui/Controls/period.png",
	[" "] = "rbxasset://textures/ui/Controls/spacebar.png",
}
local KeyCodeToTextMapping = {
	[Enum.KeyCode.LeftControl] = "Ctrl",
	[Enum.KeyCode.RightControl] = "Ctrl",
	[Enum.KeyCode.LeftAlt] = "Alt",
	[Enum.KeyCode.RightAlt] = "Alt",
	[Enum.KeyCode.F1] = "F1",
	[Enum.KeyCode.F2] = "F2",
	[Enum.KeyCode.F3] = "F3",
	[Enum.KeyCode.F4] = "F4",
	[Enum.KeyCode.F5] = "F5",
	[Enum.KeyCode.F6] = "F6",
	[Enum.KeyCode.F7] = "F7",
	[Enum.KeyCode.F8] = "F8",
	[Enum.KeyCode.F9] = "F9",
	[Enum.KeyCode.F10] = "F10",
	[Enum.KeyCode.F11] = "F11",
	[Enum.KeyCode.F12] = "F12",
}
local function getGui()
	local screenGui = playerGui:FindFirstChild("ProximityPrompts")
	if not screenGui then
		screenGui = Instance.new("ScreenGui")
		screenGui.Name = "ProximityPrompts"
		screenGui.ResetOnSpawn = false
		screenGui.Parent = playerGui
	end
	return screenGui
end
local function tweenGradient(tweenTime, gradient, offset)
	local tweenInfo = TweenInfo.new(tweenTime, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
	local property = {Offset = Vector2.new(offset, 0)}
	local tween = tweenService:Create(gradient, tweenInfo, property) 
	tween:Play()
	return function()
		tween:Cancel()
	end
end
local function createPrompt(prompt, inputType, gui)
	local promptUI = customPrompt:Clone()
	local frame = promptUI:FindFirstChild("Frame")
	local textButton = promptUI:FindFirstChild("TextButton")
	local background = frame:FindFirstChild("Background")
	local actionText = background:FindFirstChild("ActionText")
	local objectText = background:FindFirstChild("ObjectText")
	local roundBackground = background:FindFirstChild("RoundBackground")
	local buttonImage = roundBackground:FindFirstChild("Key")
	local buttonText = buttonImage:FindFirstChild("TextLabel")
	local frameTable = {roundBackground}
	local imageTable = {background, roundBackground}
	local textTable = {actionText, objectText, buttonText}
	local function updateUIFromPrompt()
		actionText.Text = prompt.ActionText
		objectText.Text = prompt.ObjectText
		if inputType == Enum.ProximityPromptInputType.Gamepad then
			if GamepadButtonImage[prompt.GamePadKeyCode] then
				buttonImage.Image = GamepadButtonImage[prompt.GamePadKeyCode]
			end
		elseif inputType == Enum.ProximityPromptInputType.Keyboard then
			buttonImage.Image = "rbxasset://textures/ui/Controls/key_single.png"
			local buttonTextString = prompt.KeyboardKeyCode.Name
			buttonText.Text = buttonTextString
		elseif inputType == Enum.ProximityPromptInputType.Touch then
			buttonImage.Image = "rbxasset://textures/ui/Controls/TouchTapIcon.png"
		end
	end
	updateUIFromPrompt()
	local tweensForFadeOut = {}
	local tweensForFadeIn = {}
	local tweenInfoFast = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	for index, object in pairs(textTable) do
		table.insert(tweensForFadeOut, tweenService:Create(object, tweenInfoFast, {TextTransparency = 1}))
		table.insert(tweensForFadeIn, tweenService:Create(object, tweenInfoFast, {TextTransparency = 0}))
	end
	for index, object in pairs(frameTable) do
		table.insert(tweensForFadeOut, tweenService:Create(object, tweenInfoFast, {BackgroundTransparency = 1}))
		table.insert(tweensForFadeIn, tweenService:Create(object, tweenInfoFast, {BackgroundTransparency = 0}))
	end
	for index, object in pairs(imageTable) do
		table.insert(tweensForFadeOut, tweenService:Create(object, tweenInfoFast, {ImageTransparency = 1}))
		table.insert(tweensForFadeIn, tweenService:Create(object, tweenInfoFast, {ImageTransparency = 0}))
	end
	
	table.insert(tweensForFadeOut, tweenService:Create(roundBackground.UIStroke, tweenInfoFast, {Transparency = 1}))
	table.insert(tweensForFadeIn, tweenService:Create(roundBackground.UIStroke, tweenInfoFast, {Transparency = 0}))
	--table.insert(tweensForFadeOut, tweenService:Create(roundFrame.UIStroke, tweenInfoFast, {Transparency = 1}))
	--table.insert(tweensForFadeIn, tweenService:Create(roundFrame.UIStroke, tweenInfoFast, {Transparency = .5}))
	--table.insert(tweensForFadeOut, tweenService:Create(buttonImage, tweenInfoFast, {ImageTransparency = 1}))
	--table.insert(tweensForFadeIn, tweenService:Create(buttonImage, tweenInfoFast, {ImageTransparency = .3}))
	table.insert(tweensForFadeOut, tweenService:Create(buttonText, tweenInfoFast, {TextTransparency = 1}))
	table.insert(tweensForFadeIn, tweenService:Create(buttonText, tweenInfoFast, {TextTransparency = 0}))
	if inputType == Enum.ProximityPromptInputType.Touch or prompt.ClickablePrompt then
		local buttonDown = false
		textButton.InputBegan:Connect(function(input)
			if (input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1) and input.UserInputType ~= Enum.UserInputState.Change then
				prompt:InputHoldBegin()
				buttonDown = true
			end
		end)
		textButton.InputEnded:Connect(function(input)
			if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
				if buttonDown then
					buttonDown = false
					prompt:InputHoldEnd()
				end
			end
		end)
		promptUI.Active = true
	end
	local tween = nil
	local colourChangeCleanup = nil
	local colourChangeCleanup2 = nil
	if prompt.HoldDuration > 0 then
		prompt.PromptButtonHoldBegan:Connect(function()
			if colourChangeCleanup then
				colourChangeCleanup()
			end
			if colourChangeCleanup2 then
				colourChangeCleanup2()
			end
			colourChangeCleanup = tweenGradient(prompt.HoldDuration, buttonText.UIGradient, 0)
			colourChangeCleanup2 = tweenGradient(prompt.HoldDuration, roundBackground.UIGradient, 1)
		end)
		prompt.PromptButtonHoldEnded:Connect(function()
			if colourChangeCleanup then
				colourChangeCleanup()
			end
			if colourChangeCleanup2 then
				colourChangeCleanup2()
			end
			colourChangeCleanup = tweenGradient(prompt.HoldDuration, buttonText.UIGradient, 1)
			colourChangeCleanup2 = tweenGradient(prompt.HoldDuration, roundBackground.UIGradient, 0)
		end)
	else
		--tweenFrame.Visible = false
	end
	local triggeredConnection
	local triggerEndedConnection
	triggeredConnection = prompt.Triggered:Connect(function()
		for index, tween in pairs(tweensForFadeOut) do
			tween:Play()
		end
	end)
	triggerEndedConnection = prompt.TriggerEnded:Connect(function()
		for index, tween in pairs(tweensForFadeIn) do
			tween:Play()
		end
	end)
	promptUI.Adornee = prompt.Parent
	promptUI.Parent = gui
	for index, tween in pairs(tweensForFadeIn) do
		tween:Play()
	end
	local function cleanupFunction()
		triggeredConnection = nil
		triggerEndedConnection = nil
		for index, tween in pairs(tweensForFadeOut) do
			tween:Play()
		end
		task.wait(.3)
		promptUI.Parent = nil
	end
	return cleanupFunction
end
local function onProximityPromptShown(prompt, inputType)
	if not localPlayer:FindFirstChild("PlayerInfo").Info.ProximityPromptsEnabled.Value then
		return
	end
	if prompt.Style == Enum.ProximityPromptStyle.Custom then
		local gui = getGui()
		local cleanupFunction = createPrompt(prompt, inputType, gui)
		prompt.PromptHidden:Wait()
		if cleanupFunction then
			cleanupFunction()
		end
		cleanupFunction = nil
	end
end
proximityPromptService.PromptShown:Connect(onProximityPromptShown)
Thanks in advance - LinusKat @ Reality Creations