Custom Proximity Prompt doesn't work on mobile

  1. What do you want to achieve?
    I want my proximity prompt to be usable/accessible on mobile platforms as well as PC.

  2. What is the issue?
    The proximity prompt is usable via PC when I press the E key, but not when I attempt to click (via PC) or tap (via mobile) on it. I’ve created a custom proximity prompt using a BillboardGui (see image below), which I think might be related to the issue?


    Screenshot 2023-12-27 at 5.15.48 PM

  3. What solutions have you tried so far?
    I’ve tried turning on and off the “ClickablePrompt” property of the Proximity Prompt… but otherwise I’m a bit stuck on what I should do.

Additional Info:

“PromptActions” Module Script (located in ReplicatedStorage)

local PromptAction = {}


function PromptAction.createAction(prompt, player)
	prompt.Enabled = false
	local parentName = prompt:FindFirstAncestorWhichIsA("Model").Name
	local plr = game.Workspace:FindFirstChild(player.Name)
	
	if parentName == "DoorC1" then
		
		plr:WaitForChild("HumanoidRootPart").CFrame = workspace.Teleports:WaitForChild("CafeI").CFrame + Vector3.new(0,10,0)
	
		
	
	elseif parentName == "DoorC2" then
		
		plr:WaitForChild("HumanoidRootPart").CFrame = workspace.Teleports:WaitForChild("CafeO").CFrame + Vector3.new(0,10,0)
	
	elseif parentName == "DoorSG1" then

		plr:WaitForChild("HumanoidRootPart").CFrame = workspace.Teleports:WaitForChild("SmallGiftI").CFrame + Vector3.new(0,10,0)
		
		
	elseif parentName == "DoorSG2" then
		
		plr:WaitForChild("HumanoidRootPart").CFrame = workspace.Teleports:WaitForChild("SmallGiftO").CFrame + Vector3.new(0,10,0)
		
		
	elseif parentName == "Espresso Machine" then
		
		--insert espresso machine script
		
		
	elseif parentName == "Oven" then

		--insert oven script
		
	elseif parentName == "SGCash" then

		--insert Small Gift Trade script
		
	elseif parentName == "Mirror" then

		--insert Customize script
		
	elseif parentName == "Crafting Table" then

		--insert Crafting script
		
	elseif parentName == "Mailbox" then

		--insert FastTravel script
		
	elseif parentName == "Ring" then
		
		local plr = game.Workspace:FindFirstChild(player.Name)
		plr:WaitForChild("HumanoidRootPart").CFrame = workspace.Ring.Part.CFrame + Vector3.new(0,10,0)
	end
	
	prompt.Enabled = true
end

return PromptAction

“Prompts” LocalScript (located in StarterPlayerScripts)

local PS = game:GetService("ProximityPromptService")
local PromptActions = require(game.ReplicatedStorage.PromptActions)

PS.PromptShown:Connect(function(prompt, inputType) --prompt, inputType is keyboard/touchpad
	if prompt.Style == Enum.ProximityPromptStyle.Default then
		return
	end
	
	local UI = prompt.BillboardUI
	UI.Enabled = true

end)

PS.PromptHidden:Connect(function(prompt, inputType)
	if prompt.Style == Enum.ProximityPromptStyle.Default then
		return
	end

	local UI = prompt.BillboardUI
	UI.Enabled = false
end)

PS.PromptTriggered:Connect(function(prompt, player)
	if prompt.Style == Enum.ProximityPromptStyle.Default then
		return
	end

	PromptActions.createAction(prompt, player)
end)

In short: How can I make it so the prompt is also clickable and/or useable via mobile devices? Is there something I’m doing wrong? Also, please LMK if you need more information! I’m happy to provide it!

Thank you for all of your help! <3

try this

local PS = game:GetService("ProximityPromptService")
local UserInputService = game:GetService("UserInputService")
local PromptActions = require(game.ReplicatedStorage.PromptActions)

PS.PromptShown:Connect(function(prompt, inputType) --prompt, inputType is keyboard/touchpad
	if prompt.Style == Enum.ProximityPromptStyle.Default then
		return
	end

	local UI = prompt.BillboardUI
	UI.Enabled = true

	if UserInputService.TouchEnabled then
		local e
		e = UI.ImageLabel.InputEnded:Connect(function(input)
			if input.UserInputType == Enum.UserInputType.Touch then
				PromptActions.createAction(prompt, game.Players.LocalPlayer)
			end
		end)

		prompt.PromptHidden:Once(function()
			e:Disconnect()
		end)
	end
end)

PS.PromptHidden:Connect(function(prompt, inputType)
	if prompt.Style == Enum.ProximityPromptStyle.Default then
		return
	end

	local UI = prompt.BillboardUI
	UI.Enabled = false
end)

PS.PromptTriggered:Connect(function(prompt, player)
	if prompt.Style == Enum.ProximityPromptStyle.Default then
		return
	end

	PromptActions.createAction(prompt, player)
end)
1 Like

Thank you!

I tried this script, but it doesn’t seem to work :confused:
No output errors though!
I tried clicking & tapping on the custom prompt, but it didn’t trigger the prompt.

1 Like

did u tried it on mobile? ||||||

1 Like

Yes, I have! Do you think it has something to do with the location of the BillboardUI?
EDIT: Location as in it’s Adornee (which is to the Prox part within the model)

Tried using an ImageButton instead of a ImageLabel and it didn’t work either :confused:

I tried to work with BillboardGui and found that it is not affected by any methods from Input, so there are several implementation options, but I think the best would be to have a separate button on the user’s screen that allows interaction with Prompt.

Try downloading the file below, then paste it into StarterGui and delete the old local script.

image

PromptGui.rbxm (5,8 КБ)

If desired, optimize the button design to suit the design of your game.