How to use PromptShown and PromptHidden with ProximityPrompts to show GUIs seperately?

Hey! I am posting about this because I’m dumb with code sometimes and the people in a discord server have no idea of what a proximity prompt is.

You probably read the title and I feel you, it’s hard to understand so I’ll explain.
Basically I want to make a custom ProximityPrompt UI. So I made it. Now I want that UI(a billboardGui)to show up when the ProximityPrompt UI is shown. And I can check if it is shown with the .PromptShown event. Currently I have made a local script that I placed in StarterPlayerScripts which shows the UI when the Prompt is shown.

local TweenService = game:GetService("TweenService")
game.ReplicatedStorage.Tween.OnClientEvent:Connect(function(tObj)
	tObj:TweenSize(UDim2.new(0.01,0,0.01,0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.5, true)
	wait(0.1)
	tObj:TweenSize(UDim2.new(0.7,0,0.7,0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.3, true)
	
end)

workspace.BlackSweater.Head.Buy.PromptShown:Connect(function()
	workspace.BlackSweater.Head.InteractGui.Enabled = true
end)

workspace.BlackSweater.Head.Buy.PromptHidden:Connect(function()
	workspace.BlackSweater.Head.InteractGui.Enabled = false
end)

But this script only works on one and I want it to work on multiple. Is there a more reliable way of doing this rather than using multiple lines of

workspace.BlackSweater.Head.Buy.PromptShown:Connect(function()
   workspace.BlackSweater.Head.InteractGui.Enabled = true
end)

workspace.BlackSweater.Head.Buy.PromptHidden:Connect(function()
   workspace.BlackSweater.Head.InteractGui.Enabled = false
end)

If so, do go ahead and reply to this post with what you have. Thank you.

1 Like