Button activated once connection not working in promptshown connection/

Hi,

I am having trouble with my minimalistic proximity system… I am trying to add mobile support by making prompts clickable, so I added a imagebutton for the player to be able to trigger the prompt. The problem is that the imagebutton.activated connection is not working for some odd reason.

Here’s the code:

ProximityPromptService.PromptShown:Connect(function(promptInstance: ProximityPrompt)
	if promptInstance.Style == Enum.ProximityPromptStyle.Default then return end
	if LocalPlayer.Character:FindFirstChild("Box") then return end
	
	local Keycode = promptInstance.KeyboardKeyCode.Name
	
	if UserInputService.TouchEnabled then
		Keycode = "CLICK"
	end
	
	if UserInputService.GamepadEnabled then
		Keycode = promptInstance.GamepadKeyCode.Name
	end
	
	local CustomProximity = Assets.Proximity:Clone()
	CustomProximity.ObjectText.Text = "<stroke>"..promptInstance.ObjectText.."</stroke>"
	CustomProximity.ActionText.Text = "<stroke><font color='rgb(245,205,48)'>["..Keycode.."]</font> - " ..promptInstance.ActionText.."</stroke>"
	CustomProximity.Parent = promptInstance.Parent
	
	local Button = CustomProximity:FindFirstChildOfClass("ImageButton")
	
	Button.Activated:Once(function(inputObject: InputObject, clickCount: number) 
		print("activated")
	end)
	
	promptInstance.PromptHidden:Once(function()
		if CustomProximity then
			CustomProximity:Destroy()
		end
	end)
	
	PlaySound(ProximitySounds.PromptShown, promptInstance, ProximitySounds)
end)

Screen Shot 2024-06-24 at 1.36.00 PM

Does the code make it all the way to the end? Add prints or breakpoints to see if it’s even connecting.

Well, it has to be going through all the way to the end because it works for pc

https://gyazo.com/7d5f2fb110b09f0ec6c7eec5fc2f26ef

ProximityPromptService.PromptShown:Connect(function(promptInstance: ProximityPrompt)
	if promptInstance.Style == Enum.ProximityPromptStyle.Default then return end
	if LocalPlayer.Character:FindFirstChild("Box") then return end
	
	local Keycode = promptInstance.KeyboardKeyCode.Name
	
	if UserInputService.TouchEnabled then
		Keycode = "CLICK"
	end
	
	if UserInputService.GamepadEnabled then
		Keycode = promptInstance.GamepadKeyCode.Name
	end
	
	local CustomProximity = Assets.Proximity:Clone()
	CustomProximity.ObjectText.Text = "<stroke>"..promptInstance.ObjectText.."</stroke>"
	CustomProximity.ActionText.Text = "<stroke><font color='rgb(245,205,48)'>["..Keycode.."]</font> - " ..promptInstance.ActionText.."</stroke>"
	CustomProximity.Parent = promptInstance.Parent
	
	local Button = CustomProximity:FindFirstChild("ImageButton")
	
	print("before connec")
-- changed once to connect from skepticism (yielded same result)
	Button.Activated:Connect(function(inputObject: InputObject, clickCount: number) 
		print("activated")
	end)
	print("after connec")
	promptInstance.PromptHidden:Once(function()
		if CustomProximity then
			CustomProximity:Destroy()
		end
	end)
	
	PlaySound(ProximitySounds.PromptShown, promptInstance, ProximitySounds)
end)

Figured it out. Interestingly enough, BillboardGuis not parented to the PlayerGui will ignore user inputs from GuiObjects. Parent it to the PlayerGui and set the Adornee instead.

1 Like

Oh wow, I did realize that the default proximity went to playergui. I would have never solved that issue without asking. Thank you, it worked!

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