Custom Proximity Prompt For Mobile

As the title states, I am trying to make a custom proximity prompt that when is held by a mobile user, will trigger.

1 Like

i found a post, maybe it will helps you:

2 Likes

Thanks for your reply!

I used the context from the linked forum and got this.

local promt = game.Workspace.Folder.ProxPart.ProximityPrompt
local bb = game.Workspace.Folder.ProxPart.BillboardGui
local cvr = game.Workspace.Folder.ProxPart.BillboardGui.Frame.Frame
local TweenService = game:GetService("TweenService")

local LPlayer = game.Players.LocalPlayer
local PlayerName = LPlayer.Name

local inputtype = game:GetService("UserInputService")
if inputtype == Enum.ProximityPromptInputType.Touch or promt.ClickablePrompt then
	local button = bb.Frame.TextButton

	local buttonDown = false

	button.InputBegan:Connect(function(input)
		if (input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1) and
			input.UserInputState ~= Enum.UserInputState.Change then
			promt:InputHoldBegin()
			buttonDown = true
			print("trig")
		end
	end)
	button.InputEnded:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
			if buttonDown then
				buttonDown = false
				promt:InputHoldEnd()
			end
		end
	end)
end

It doesn’t seem to be working.
Ideas?

put some prints at different line of the code to see where it prints and where it doesnt like one after and one before:

if inputtype == Enum.ProximityPromptInputType.Touch or promt.ClickablePrompt then

do not forget the print, it will always be your best friend

1 Like

Like this???

local promt = game.Workspace.Folder.ProxPart.ProximityPrompt
local bb = game.Workspace.Folder.ProxPart.BillboardGui
local cvr = game.Workspace.Folder.ProxPart.BillboardGui.Frame.Frame
local TweenService = game:GetService("TweenService")

local LPlayer = game.Players.LocalPlayer
local PlayerName = LPlayer.Name

local inputtype = game:GetService("UserInputService")
if inputtype == Enum.ProximityPromptInputType.Touch or promt.ClickablePrompt then
	local button = bb.Frame.TextButton

	local buttonDown = false

	button.InputBegan:Connect(function(input)
		if (input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1) and
			input.UserInputState ~= Enum.UserInputState.Change then
			promt:InputHoldBegin()
			buttonDown = true
			print("trig")
		end
	end)
	button.InputEnded:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
			if buttonDown then
				buttonDown = false
				promt:InputHoldEnd()
			end
		end
	end)
end
1 Like

Personnaly i would use a print at every step even if i over use this. Here you only used 1 print

2 Likes

Hey. I still have no clue why this isn’t working. Ideas?

local promt = game.Workspace.Folder.ProxPart.ProximityPrompt
local bb = game.Workspace.Folder.ProxPart.BillboardGui
local cvr = game.Workspace.Folder.ProxPart.BillboardGui.Frame.Frame
local TweenService = game:GetService("TweenService")

local LPlayer = game.Players.LocalPlayer
local PlayerName = LPlayer.Name

local inputtype = game:GetService("UserInputService")
if inputtype == Enum.ProximityPromptInputType.Touch or promt.ClickablePrompt then
	print("trig1")
	local button = bb.Frame.TextButton

	local buttonDown = false

	button.InputBegan:Connect(function(input)
		print("trig111")
		if (input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1) and
			input.UserInputState ~= Enum.UserInputState.Change then
			promt:InputHoldBegin()
			buttonDown = true
			print("trig")
		end
	end)
	button.InputEnded:Connect(function(input)
		print("tr")
		if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
			
			if buttonDown then
				buttonDown = false
				promt:InputHoldEnd()
			end
		end
	end)
end

all prints are actually printing?

No. Only the first. (trig1)

(30chs)

I will then ask you, what are you tying to achieve? making a custom proximity prompt? you could achieve that by looking on google and modifying the look of the prompt guis

Kinda, I am trying to make it mobile friendly…

With UserInputService, there are events for mobile like:

local UserInputService = game:GetService("UserInputService")

UserInputService.TouchTap:Connect(function()
	
end)

UserInputService.TouchStarted:Connect(function()
	
end)

UserInputService.TouchMoved:Connect(function()
	
end)

UserInputService.TouchEnded:Connect(function()
	
end)

UserInputService.TouchPan:Connect(function()
	
end)

And there are more Touch event for tactile screens

Ill try it. Thanks

(30 chssss)

now how can I check if they are clicking on the prompt, not just anywhere on the screen?

You can check if the player is clicking on the prompt by using the ‘Target’ property of the input object.

local promt = game.Workspace.Folder.ProxPart.ProximityPrompt
local bb = game.Workspace.Folder.ProxPart.BillboardGui
local cvr = game.Workspace.Folder.ProxPart.BillboardGui.Frame.Frame
local TweenService = game:GetService("TweenService")

local LPlayer = game.Players.LocalPlayer
local PlayerName = LPlayer.Name

local inputtype = game:GetService("UserInputService")
if inputtype == Enum.ProximityPromptInputType.Touch or promt.ClickablePrompt then
	print("trig1")
	local button = bb.Frame.TextButton

	local buttonDown = false

	button.InputBegan:Connect(function(input)
		print("trig111")
		if (input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1) and
			input.UserInputState ~= Enum.UserInputState.Change then
			if input.Target == button then -- check if the target of the input is the button
				promt:InputHoldBegin()
				buttonDown = true
				print("trig")
			end
		end
	end)
	button.InputEnded:Connect(function(input)
		print("tr")
		if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
			if input.Target == button and buttonDown then -- check if the target of the input is the button
				buttonDown = false
				promt:InputHoldEnd()
			end
		end
	end)
end

Button would be an example. But change it how’d you prefer.

that doesnt seem to be working. nothing comes in output
image

@Boustifail

Do you know how I can check if they are clicking on the prompt?

Sorry for the late answer. To check if they press then add a print inside one of the event simply

Can you elaborate a little? I dont understand.