Hello DevForum, I have returned with yet another issue, this time including customising ProximityPrompts. My custom ProximityPrompt currently works when you initially interact with it, however when I walk away from it and walk back up to it, it fails to regenerate to prompt. I have tried asking for help with the Roblox Studio Community Discord server however because it is a niche issue, I failed to get the correct help. Here is the code that I created:
--[[
Title: CustomPrompts.lua
Author: 7hDev
Description: Customised proximity prompts.
]]
local Players = game:GetService("Players")
local PromptService = game:GetService("ProximityPromptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Player = Players.LocalPlayer
local CustomPrompt = ReplicatedStorage:WaitForChild("Prompt")
local function CreatePrompt(Prompt, InputType, Gui)
local PromptUI = CustomPrompt:Clone()
PromptUI:WaitForChild("Frame").Header.ObjectText.Text = workspace.Example.ClothingName.Value
PromptUI.Adornee = Prompt.Parent
PromptUI.Parent = Gui
print(PromptUI.Parent)
local Info = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false)
local Tweens = {
FrameTween = TweenService:Create(PromptUI.Frame, Info, {ImageTransparency = 0.2});
HeaderTween = TweenService:Create(PromptUI.Frame.Header.ObjectText, Info, {TextTransparency = 0});
BuyTween = TweenService:Create(PromptUI.Frame.Buy.TextButton, Info, {TextTransparency = 0});
BasketTween = TweenService:Create(PromptUI.Frame.Basket.TextButton, Info, {TextTransparency = 0});
PreviewTween = TweenService:Create(PromptUI.Frame.Preview.TextButton, Info, {TextTransparency = 0});
}
Tweens["FrameTween"]:Play()
task.wait(0.2)
for i,v in pairs(Tweens) do
if v ~= "HeaderTween" then
v:Play()
end
end
end
local function GetScreenGui()
if Player:WaitForChild("PlayerGui"):FindFirstChild("ProximityPrompts") == nil then
local ScreenGui = Instance.new("ScreenGui", Player.PlayerGui)
ScreenGui.Name = "ProximityPrompts"
ScreenGui.ResetOnSpawn = false
return ScreenGui
end
end
PromptService.PromptShown:Connect(function(Prompt, InputType)
if Prompt.Style == Enum.ProximityPromptStyle.Default then
return
end
local Gui = GetScreenGui()
CreatePrompt(Prompt, InputType, Gui)
Prompt.PromptHidden:Wait()
for i,v in pairs(Player.PlayerGui.ProximityPrompts:GetChildren()) do
if v.Name == "Prompt" then
v:Destroy()
end
end
end)