Hello forrummers! I’m currently working on a custom proximityPrompt system, and i have mainly everything out of the way but there’s 1 issue left, I’m trying to make it so that the UI can be clicked to trigger the prompt, but since its a billboardGui that’s being cloned in the chimney, we can’t use stuff like adornee from the playerGui (except if I’m unaware of something).
you can see here:
this is my script:
local ProximityPromptService = game:GetService("ProximityPromptService")
local TweenService = game:GetService("TweenService")
local currentGui
local function animateGui(gui, isShowing)
local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local targetSize = isShowing and UDim2.new(2.5, 0, 2.5, 0) or UDim2.new(0, 0, 0, 0)
local tween = TweenService:Create(gui, tweenInfo, { Size = targetSize })
tween:Play()
if not isShowing then
tween.Completed:Connect(function()
gui:Destroy()
end)
end
end
local function setupButton(button, prompt)
button.MouseButton1Click:Connect(function()
prompt:InputHoldBegin()
wait()
prompt:InputHoldEnd()
end)
end
ProximityPromptService.PromptShown:Connect(function(prompt)
currentGui = game.ReplicatedStorage.BillboardGui:Clone()
currentGui.Size = UDim2.new(0, 0, 0, 0)
currentGui.Parent = prompt.Parent
local button = currentGui:FindFirstChild("TextButton")
if button then
setupButton(button, prompt)
end
animateGui(currentGui, true)
end)
-- Hide prompt
ProximityPromptService.PromptHidden:Connect(function(prompt)
if currentGui then
animateGui(currentGui, false)
currentGui = nil
end
end)
I think the Billboard UI must be a child of ScreenGUI, and not of the object. Move it there, and you still set the Adornee to the chimney and it’ll appear exactly the same, but the button will work.
I had the same thing happen last week.
It’s seemingly so useful to have the GUI element as a clonable item (as you have)… I would suggest actually leaving it in there, cloning it, and then in your setupButton(button, prompt), reparenting the prox to ScreenGUI.
I was able to make it work using adornee! There is a slight issue with my script though, even when i click the button, it’s not triggering the prompt. I’m not sure if this is even the right way to do it ngl
local ProximityPromptService = game:GetService("ProximityPromptService")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local currentGui
local function animateGui(gui, isShowing)
local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local targetSize = isShowing and UDim2.new(2.5, 0, 2.5, 0) or UDim2.new(0, 0, 0, 0)
local tween = TweenService:Create(gui, tweenInfo, { Size = targetSize })
tween:Play()
if not isShowing then
tween.Completed:Connect(function()
gui:Destroy()
end)
end
end
local function setupButton(button, prompt)
button.MouseButton1Click:Connect(function()
prompt:Triggered(Players.LocalPlayer)
end)
end
local function isPlayerInRange(prompt)
local character = Players.LocalPlayer.Character
if not character or not character:FindFirstChild("HumanoidRootPart") then
return false
end
local playerPosition = character.HumanoidRootPart.Position
local promptPosition = prompt.Parent.Position
local distance = (playerPosition - promptPosition).Magnitude
return distance <= prompt.MaxActivationDistance
end
ProximityPromptService.PromptShown:Connect(function(prompt)
if not isPlayerInRange(prompt) then
return
end
local player = Players.LocalPlayer
if not player then return end
currentGui = game.ReplicatedStorage.BillboardGui:Clone()
currentGui.Size = UDim2.new(0, 0, 0, 0)
currentGui.Adornee = prompt.Parent
currentGui.Parent = player:WaitForChild("PlayerGui")
local button = currentGui:FindFirstChild("TextButton")
if button then
setupButton(button, prompt)
end
animateGui(currentGui, true)
end)
ProximityPromptService.PromptHidden:Connect(function(prompt)
if currentGui then
animateGui(currentGui, false)
currentGui = nil
end
end)