Errors occuring when I attempt to change proximity prompt text

I am making a door system that is compatible with (or should be compatible with) my custom proximity prompts, but whenever I want to change the text of the prompt and apply it to the gui, the proximity prompt script prints this:

Despite being the object text definitely is a child of PromptUI:
image

And once I used :WaitForChild(“ObjectText”) instead of just Parent.Child this prints:

I honestly have run out of ideas and need help with this, if anyone wants to help here’s my script.

local replicatedstorage = game:GetService("ReplicatedStorage")
local proximitypromptservice = game:GetService("ProximityPromptService")
local tweenservice = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local hum = player.Character:FindFirstChild("Humanoid")

local function PressedTween (prompt)
    local pressedtweengoal = {}
    pressedtweengoal.Size = UDim2.new(0.20, 0, 0.65, 0)
    pressedtweengoal.BackgroundColor3 = Color3.new(0.694118, 0.694118, 0.694118)
    local pressedtweeninfo = TweenInfo.new(
        .1,
        Enum.EasingStyle.Linear,
        Enum.EasingDirection.Out,
        0,
        false
    )
    local PressedTween = tweenservice:Create(prompt.Parent:FindFirstChild("PromptUI").InputText, pressedtweeninfo, pressedtweengoal)
    PressedTween:Play()
end

local function ReleasedTween (prompt)
    if prompt.Parent:FindFirstChild("PromptUI") then
        local ReleasedTweengoal = {}
        ReleasedTweengoal.Size = UDim2.new(0.25, 0, 0.7, 0)
        ReleasedTweengoal.BackgroundColor3 = Color3.new(1, 1, 1)
        local ReleasedTweenInfo = TweenInfo.new(
            .1,
            Enum.EasingStyle.Linear,
            Enum.EasingDirection.Out,
            0,
            false
        )

        local ReleasedTween = tweenservice:Create(prompt.Parent:FindFirstChild("PromptUI").InputText, ReleasedTweenInfo, ReleasedTweengoal)
        ReleasedTween:Play()
    end
    
end



proximitypromptservice.PromptShown:Connect(function(prompt)
    if prompt.Style == Enum.ProximityPromptStyle.Default then
        return
    end
    
    local custompromptui = replicatedstorage.PromptUI:Clone()
    custompromptui.Parent = prompt.Parent
    custompromptui:WaitForChild("ObjectText").Text = prompt.ObjectText
    custompromptui:WaitForChild("ActionText").Text = prompt.ActionText
    custompromptui:WaitForChild("InputText").Text = `{prompt.KeyboardKeyCode.Name}`
    
    prompt.Changed:Connect(function()
        custompromptui:WaitForChild("ObjectText").Text = prompt.ObjectText -- Where the errors are occuring.
        custompromptui:WaitForChild("ActionText").Text = prompt.ActionText
    end)
end)

proximitypromptservice.PromptHidden:Connect(function(prompt)
    if prompt.Style == Enum.ProximityPromptStyle.Default then
        return
    end
    local custompromptui = prompt.Parent.PromptUI
    custompromptui:Remove()
end)

proximitypromptservice.PromptTriggered:Connect(function(prompt)
    PressedTween(prompt)
    wait(0.1)
    ReleasedTween(prompt)
end)

proximitypromptservice.PromptButtonHoldBegan:Connect(function(prompt)
    PressedTween(prompt)
end)

proximitypromptservice.PromptButtonHoldEnded:Connect(function(prompt)
    ReleasedTween(prompt)
end)

Hello Bones, I’m not that good at coding but i think to fix this issue you have to store the Text labels in a variable like this

proximitypromptservice.PromptShown:Connect(function(prompt)
	if prompt.Style == Enum.ProximityPromptStyle.Default then
		return
	end

	local custompromptui = replicatedstorage.PromptUI:Clone()
	custompromptui.Parent = prompt.Parent
	
	local objectText = custompromptui:WaitForChild("ObjectText")
	local actionText = custompromptui:WaitForChild("ActionText")
	local inputText = custompromptui:WaitForChild("InputText")
	
	objectText.Text = prompt.ObjectText
	actionText.Text = prompt.ActionText
	inputText.Text = `{prompt.KeyboardKeyCode.Name}`

	custompromptui.Changed:Connect(function()
		objectText = prompt.ObjectText 
		objectText = prompt.ActionText
	end)
end)

the thing that causes the error is that the billboardGui is removed when the prompt is hidden while Waiting For Child

hopefully you get what i mean !

I get you, but even if its removed shouldn’t it not matter? Because I’m changing the prompt instance itself, and even when the prompt is hidden it will show up again with the changed value.

The object you are looking for is the “ActionText” if you are referring to what the player sees from a distance?

:Remove is not a valid method of a prompt, change that to :Destroy

No because the proximity prompt has an Action text and ObjectText, and so does my GUI

I can try that, later today, but I dont know if this is my issue

Well that’s the only thing I see that is wrong

Ok fine i’m lying I had a similar issue 4 days ago where my script couldn’t find the tool even though it was right there. I fixed it but can’t rmb how :confused:

was something you changed or added that fixed the reference?

Ok I rmbered, though it isn’t related to urs.
I was trying to drop a tool from my character by pressing backspace, forgetting it was a core binding. So the core function ran first and deleted the part before mine ran, so my code couldn’t find the tool and caused the error

I stand by the :Remove claim

ObjectText and ActionText are both properties for the Proximity prompt itself.
Click on the Proximity prompt and look at the properties window.

–script inside the prompt for testing
local prompt = script.Parent
prompt.ObjectText=“objext”
prompt.ActionText=“action”

I mean why do you have text labels inside the prompt?
I’m sure it’s hitting that…

(maybe)
The Proximity prompt has a property named ObjectText but, you also have a text label within it by the same name … Making prompt.ObjectText not go to the property as it now hits the file within it.

Is this how you make Custom prompts vs Default? I’m talking about style = Default.

Yeah but isn’t he explicitly referencing the gui’s elements? So how would that cause the error

there was an issue in the code that was my mistake, i fixed it and i think its what you want to, you could try it if not then that’s okay. :smile:

proximitypromptservice.PromptShown:Connect(function(prompt)
	if prompt.Style == Enum.ProximityPromptStyle.Default then
		return
	end

	local custompromptui = replicatedstorage.PromptUI:Clone()
	custompromptui.Parent = prompt.Parent

	local objectText = custompromptui:WaitForChild("ObjectText")
	local actionText = custompromptui:WaitForChild("ActionText")
	local inputText = custompromptui:WaitForChild("InputText")

	objectText.Text = prompt.ObjectText
	actionText.Text = prompt.ActionText
	inputText.Text = `{prompt.KeyboardKeyCode.Name}`

	prompt.Changed:Connect(function()
		objectText = prompt.ObjectText 
		actionText = prompt.ActionText
	end)
end)

The text labels don’t go in the proximity prompt instance, they go into a billboardGUI which is a sibling of the instance, default proximity prompts use the default Roblox proximity prompt, and custom basically makes it invisible so you can modify it via the method I used. And I’m not having troubles referencing the proximity prompts, but only the ObjectText text label

I can try this, as well as the :Destroy() instead of :Remove() method, I am also thinking it might be possible the problem is that I’m changing the ProximityPrompt text values on a server script and then changing the GUI text on the local script, but even then it still changes the text so it cant be the issue

my bad again i forgot to add .Text but its okay i have a really basic knowledge about proximity prompts i mean atleast i tried to help :sob:

I also wanna note that the text indeed changes successfully, but these errors are just randomly showing up and I don’t know why and I’d rather have an empty error log rather than overflowing

oh, i tried the client side and its working but in the server side i dont know anything so i cant help with that sorry

Can you share the server script too? Also, Can you share the explorer tab and the gui’s parencies after the error occurs without stopping the game?

the server script for the door that changes the proximity prompts text?