Custom prompt doesn't show

I have used a script to clone a custom proximityprompt from replicatedStorage.
For some reason the prompt is not showing when hovering over a part with a proximityprompt in it.

The script seem to go through all the code, as the “cleanupFunction” recognizes that there is no prompt to clean up, creating an error confirming what is seen in-game.

local proxService = game:GetService("ProximityPromptService")
local players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")

local localPlayer = players.LocalPlayer

local playerGui = localPlayer:WaitForChild("PlayerGui")
local custPrompt = RS:WaitForChild("Prompt")

local function getScreenGui()
end

local function createPrompt(promt, inputType, gui)
	local promptUI = custPrompt:Clone()	
	
	promptUI.Adornee = promt.Parent
	promptUI.Parent = gui
	
	local function cleanupFunction()
		promptUI.Parent = nil
	end
	
	return cleanupFunction()
end



proxService.PromptShown:Connect(function(promt, inputType)
	if promt.Style == Enum.ProximityPromptStyle.Default then
		return
	end
	
	local gui = getScreenGui()
	
	local cleanupFunction = createPrompt(promt, inputType, gui)
	
	promt.PromptHidden:Wait()
	
	cleanupFunction()
end)

I think you meant:

	return cleanupFunction

it should be () (confirmed after testing)
also it is not that part of the script that is broken

It shouldn’t be. Your calling the function after meaning that you need to return the function and not return calling it as calling it returns nil.

2 Likes

from my understandment, the nil error is caused by the prompt not being a child of the part with the proximity in it. When doing as you suggest, the error doesn’t even show, which would mean it doesn’t check for if the prompt is there (which would mean the code doesn’t run)

1 Like

furthermore, when I set the parent to the part directly, it prints that the prompt is a child, but it doesn’t show in the actual game…

I tried again and it seems like that you were indeed correct. Though it doesn’t solve the problem.

So what’s the problem now, after you changed it?

Your getScreenGui() function is supposed to return a Gui to parent your promptUI to, but it doesn’t return anything. This results in your promptUI getting parented to nil, instead of making it visible. You should finish your getScreenGui() function to fix it.

1 Like

Because the getScreenGui function returns nothong meaning that you parent the prompt to nil.

1 Like

Thought ProximityPrompts didn’t need a screengui to function, but I see how it works now, thanks.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.