Need Help with Proximity Prompts

Hello, I am trying to make a script that changes the action text of my Proximity Prompt.
I made a list of the text that will show depending on the action needs to be done
hers my script:

local v9226 = script.Parent.ClosestPart


v9226.Patties = "Get Patties"
v9226.Box = "Search Box" -- If its a box use this text


function CH()
	script.Parent.Main_Frame.Action.Text = v9226 -- Change Text
	
	
end

CH()

So basically, if the v9226 value equals Box, then it should print “Search Box”, but it doesn’t. What am I doing wrong?

You’re just calling the CH function once, meaning the function only runs once, meaning the text only gets updated once.

If you can get a reference to the ProximityPrompt, you can use the PromptShown event to update every time the prompt gets shown:

https://developer.roblox.com/en-us/api-reference/event/ProximityPrompt/PromptShown

local proximityPrompt = ... 
proximityPrompt.PromptShown:Connect(CH)

Ok that worked! Thank you for your help