Button not working for custom proximity prompt

im trying to make a custom proximity prompt but my button wont work at all. im trying to get it to print something when i clicked / tapped.

function module.PromptVisibility(p)
	
	local function claimTree(p)
		print("tree was claimed by: "..p.Name.."!")
	end

	for _, tree in pairs(tree_folder:GetChildren()) do
		if tree:IsA("BasePart") then
			if tree:FindFirstChild("claim_UI") then
				local claim_UI = tree:WaitForChild("claim_UI")
				local claim_frame = claim_UI:WaitForChild("claim_frame")
				local control_button:TextButton = claim_frame:WaitForChild("control_button")
				for _, prompt in pairs(tree:GetChildren()) do
					if prompt:IsA("ProximityPrompt") then
						prompt.PromptShown:Connect(function()
							claim_frame.Visible = true
						end)

						prompt.PromptHidden:Connect(function()
							claim_frame.Visible = false
						end)
						
						control_button.InputBegan:Connect(function(inp)
							if inp.UserInputType == Enum.UserInputType.MouseButton1 or Enum.UserInputType.Touch then
								claimTree(p)
							end
						end)
					end
				end
			end
		end
	end
end

image

Custom Proximity Prompts cannot be triggered by just clicking them. You need to have some sort of input like “E”, so it has something to go off of.

Also,

Should be OUTSIDE of a function. It cannot be called upon if it’s inside of the “claimTree(p)”, as it would already need to be running for it to listen out.

2 Likes

Change control_button.InputBegan to control_button.TouchTap.