I don’t know a lot about proximity prompts, and I tried making my script for custom proximity prompt. But now when I go to a part that triggers the script and then immediatly go back, the proximity prompt just stays there and doesn’t hide, and then the second time I go to a part it makes another proximity prompt show up. But if I stay a bit within a radius of proximity prompt It doesn’t happen. Here is my code :
local UserInputService = game:GetService("UserInputService")
local ProximityPromptService = game:GetService("ProximityPromptService")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local localPlayer = Players.LocalPlayer
local playerGui = localPlayer:WaitForChild("PlayerGui")
local customPrompt = ReplicatedStorage:WaitForChild("Prompt")
local function getScreenGui()
local screenGui = playerGui:FindFirstChild("ProximityPrompts")
if screenGui == nil then
screenGui = Instance.new("ScreenGui")
screenGui.Name = "ProximityPrompts"
screenGui.ResetOnSpawn = false
screenGui.Parent = playerGui
end
return screenGui
end
ProximityPromptService.PromptShown:Connect(function(prompt)
if prompt.Style == Enum.ProximityPromptStyle.Default then return end
local gui = getScreenGui(prompt)
local promptUI = customPrompt:Clone()
local frame = promptUI:WaitForChild("Frame")
local fillingF = frame:WaitForChild("FillingFrame")
local Beam = Instance.new("Beam")
Beam.Parent = prompt.Parent
Beam.Attachment0 = localPlayer.Character:WaitForChild("HumanoidRootPart"):WaitForChild("RootAttachment")
Beam.Attachment1 = prompt.Parent:WaitForChild("Attachment")
Beam.Enabled = true
Beam.Width0 = 0.03
Beam.Width1 = 0.03
Beam.FaceCamera = true
Beam.Transparency = NumberSequence.new(1)
Beam.Texture = "rbxassetid://10794085322"
Beam.TextureMode = Enum.TextureMode.Wrap
Beam.TextureSpeed = 0.5
Beam.LightInfluence = 0
Beam.LightEmission = 0.5
-- Tween Variables
local tweenInfoFastIn = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tweenInfoFastOut = TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local FadeOutTween = TweenService:Create(frame, tweenInfoFastOut, { Size = UDim2.fromScale(0, 1), BackgroundTransparency = 1, Visible = false })
local FadeInTween = TweenService:Create(frame, tweenInfoFastIn, { Size = UDim2.fromScale(1, 1), BackgroundTransparency = 0.5, Visible = true })
local HoldOutTween = TweenService:Create(fillingF, tweenInfoFastIn, { Size = UDim2.fromScale(1, 1), Visible = true})
local HoldInTween = TweenService:Create(fillingF, tweenInfoFastOut, { Size = UDim2.fromScale(0, 1), Visible = false})
prompt.PromptButtonHoldBegan:Connect(function()
HoldOutTween:Play()
end)
prompt.PromptButtonHoldEnded:Connect(function()
HoldInTween:Play()
end)
-- Make the Prompt actually show up on screen
promptUI.Adornee = prompt.Parent
promptUI.Parent = gui
FadeInTween:Play()
for i = 1, 10 do
wait(0.003)
Beam.Transparency = NumberSequence.new(1 - 0.1 * i)
end
prompt.PromptHidden:Connect(function()
for i = 1, 10 do
wait(0.003)
Beam.Transparency = NumberSequence.new(0.1 * i)
end
Beam:Destroy()
FadeOutTween:Play()
promptUI.Parent = nil
end)
end)
And the video of what It looks like:
robloxapp-20250215-1824595.wmv (1.7 MB)
the first time I go to a part I make it go the way I intended and the second time it’s the way it looks when the issue happens.