Script saying Frame doesn't exist when it does

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a custom proximity prompt.

  2. What is the issue? Include screenshots / videos if possible!
    The issue is that I have a Frame called “Key” that displays the KeyboardKeyCode but the script says it doesn’t exist.
    Here is the “Key” Frame:
    Screenshot 2025-03-22 110400

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked on the DevForum, found some, but no solutions to this issue.

The custom proximity script:

	if inputType == Enum.ProximityPromptInputType.Touch then
		-- Mobile support
		local inputType = GetInputType()
		print(inputType)
		if inputType == "Touch" then
			CustomProximity.Icon.Visible = true
			CustomProximity.Key.Visible = false
			if promptInstance.ObjectText == "Item" or promptInstance.ObjectText == "Drawer" then
				CustomProximity.Icon.Image = "rbxassetid://78519839121496"
			else
				CustomProximity.Icon.Image = "rbxassetid://94120149145024"
			end
			interactButton.Visible = true
			CustomProximity.ObjectText.Text = promptInstance.ObjectText
			CustomProximity.ActionText.Text = promptInstance.ActionText
			CustomProximity.Parent = promptInstance.Parent
			interactButton.InputBegan:Connect(function(input)
				print("Input began")
				if promptInstance.Style == Enum.ProximityPromptStyle.Default then return end
				promptInstance:InputHoldBegin()
			end)
			interactButton.InputEnded:Connect(function()
				print("Input Ended")
				if promptInstance.Style == Enum.ProximityPromptStyle.Default then return end
				promptInstance:InputHoldEnd()
			end)
		else
			interactButton.Visible = false
			CustomProximity.Icon.Visible = false
			CustomProximity.Key.Visible = true
			CustomProximity.Key.KeyboardKeyCode.Text = tostring(promptInstance.KeyboardKeyCode)
			CustomProximity.ObjectText.Text = promptInstance.ObjectText
			CustomProximity.ActionText.Text = promptInstance.ActionText
			CustomProximity.Parent = promptInstance.Parent
		end 
	else
		CustomProximity.ObjectText.Text = promptInstance.ObjectText
		CustomProximity.ActionText.Text = promptInstance.ActionText
		CustomProximity.Parent = promptInstance.Parent
	end
	promptInstance.Triggered:Connect(function()
		local info = TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, true, 0)
		if GetInputType() == "Touch" then
			local tween = TweenService:Create(CustomProximity:WaitForChild("Icon"), info, {Size = UDim2.new(0.17, 0, 0.3, 0)})
			tween:Play()
		else
			local tween = TweenService:Create(CustomProximity:WaitForChild("Key"), info, {Size = UDim2.new(0.17, 0, 0.3, 0)})
			tween:Play()
		end
	end)
	promptInstance.PromptHidden:Once(function()
		interactButton.Visible = false
		clone:Destroy()
		if CustomProximity then
			CustomProximity:Destroy()
		end
	end)
end)

The first part of the script works, when I set the “Key” visibility to true, but the rest doesn’t work.
Here is a screenshot of the output:

Screenshot 2025-03-22 110414

It is on the line of the Tween, by the way.
Also I tried without the :WaitForChild() but it just gave me the “Not a vaild member” error in the output.

The infinite yield possible error appears when :WaitForChild() is waiting for something that does not exist yet, to appear. In this case, the error is caused by the WaitForChild function not being able to detect whether the Key has appeared.

If I were you, I would firstly ensure the Key exists as a child of CustomProximity before calling the CustomProximity:WaitForChild("Key") line of code. You can do this by writing the below code that prints a warning message in the output if Key does not exist as a child of CustomProximity.

if not CustomProximity:FindFirstChild("Key") then
    warn("CustomProximity does not have a child named 'Key'")
    return
end

Let me know whether the above warning message appears in the output.

1 Like

Yes, it does appear in the output, but it is strange because it works for some prompts that are set to custom style but not for others. I have one prompt that is a copy of another one that works but strangely, it shows the warning message in the output.
Here is a video of what I mean:


Also sorry if the quality is bad, there was a 10MB upload limit

I’m sorry, I don’t understand what the issue is. From what I see and understand from the video, the warning message is being printed in the output because the child object is a Door and not the Key.

The shared warning message code is only to check if CustomProximity does not have a child named “Key”. If not CustomProximity:FindFirstChild("Key") is true, then the warning message is printed. The video shows that the child object is a Door and hence, the not CustomProximity:FindFirstChild("Key") value is true.

No, the key is the E key that shows up on screen, not the key object. Also the CustomProximity’s parent is the key’s parent so that would not make sense. I mean the key as in the Frame key not the key object that is highlighted. If you still don’t understand then maybe this image will help:

I still don’t have a solution, can someone please help?

I’m sure you didn’t read my post because in the title I said a “Frame” doesn’t exist and also in the topic I said the issue was
“I have a Frame called “Key” that displays the KeyboardKeyCode but the script says it doesn’t exist.”
I even also said “Here is the “Key” Frame:” and showed an image of a “Frame” inside of the CustomProximity BillboardGui. So what makes you think that the “Key” tool has anything to do with this? The key was just an example of a tool that works with the prompt. The key I am talking about is the “Key” Frame. Also the child object is not a “Door”, the parent object is a door. Do you even understand how BillboardGui’s work? You cannot have a working BillboardGui if the part is a child of it. Please read my post first before trying solutions that would never work. And now you just abandon this post because nobody in the entire DevForum knows how to solve this issue. Also I am sorry if I am sounding angry, I am just a bit disappointed that no one knows how to solve this issue. It has been bugging me for days and it is really annoying. If you aren’t going to help @RedBoyHD_YT then at least don’t post wrong solutions.

Could you possibly show the part of the script where uou get the customproxminty instance?
(Also i will be able to help for the next 3 minutes)

1 Like

Do you mean the other part of the script? If so, here it is:

ProximityPromptService.PromptShown:Connect(function(promptInstance, inputType)
	local enabled = true
	if promptInstance.Style == Enum.ProximityPromptStyle.Default then return end
	coroutine.wrap(function()
		while task.wait(1) do
			if promptInstance.Enabled == false then
				enabled = false
				return
			else
				enabled = true
			end
		end
	end)()
	-- Highlighting Object
	local clone = highlight:Clone()
	if promptInstance.Parent.Parent.Name == "Drawer" then
		clone.Adornee = promptInstance.Parent.Parent.Handle:FindFirstChild("UnionOperation")
		clone.Parent = promptInstance.Parent.Parent.Handle:FindFirstChild("UnionOperation")
	elseif promptInstance.Parent:FindFirstChild("Coin") then
		local coin = promptInstance.Parent.Coin.Part
		clone.Adornee = coin
		clone.Parent = coin
	elseif promptInstance.Parent:FindFirstChild("Key") and promptInstance.Parent.Parent.Name ~= "ElectricalKey" then
		local handle = promptInstance.Parent.Key.Handle
		clone.Adornee = handle
		clone.Parent = handle
	elseif promptInstance.Parent.Parent.Name == "ElectricalKey" then
		local elecHandle = promptInstance.Parent.Parent
		clone.Adornee = elecHandle
		clone.Parent = elecHandle
	elseif promptInstance.Parent.Parent.Name == "Closet" then
		local door = promptInstance.Parent.Parent.Barrier
		clone.Adornee = door
		clone.Parent = door
	elseif promptInstance.Parent.Name == "Lock" then
		local lock = promptInstance.Parent
		clone.Adornee = lock
		clone.Parent = lock
	else
		clone.Adornee = promptInstance:FindFirstAncestorOfClass("BasePart")
		clone.Parent = promptInstance:FindFirstAncestorOfClass("BasePart")
	end
	local CustomProximity = game.ReplicatedStorage:WaitForChild("CustomProximity"):Clone()
	CustomProximity.ObjectText.Text = promptInstance.ObjectText
	CustomProximity.ActionText.Text = promptInstance.ActionText
	CustomProximity.Parent = promptInstance.Parent

Also sorry if I’m a bit late, I was busy in the last 15 min

Also what I don’t understand is that I am cloning the same BillboardGui, the only thing that is changing is the BillboardGui’s Parent. There is a Frame named “Key” inside the BillboardGui but when I parent the Gui to the lock of the door, it fails and the key apparently does not exist. Also I checked while the game was running inside of the BillboardGui if there was a Frame and there was. On another note, @MrNobodyDev weren’t you going to help?

Maybe you put a space and named it "Key " instead of Key

1 Like

No, that wouldn’t be possible because other prompts work, it’s just some of them like the door prompt in the video don’t work. Like I said in the post, it works fine for the key and other prompts but it doesn’t seem to work with the door. Though it could be possible that there are multiple prompts in the door object.

Yeah sorry i had to go off to go to sleep. Could you try add a print inside of the PromptHidden function just to check that maybe get destroyed?

I added some extra warnings but it seems that when the prompt is hidden, it print that there is a key but when it is triggered, it warns that no key has been found. Here is an image of the output to visualize what I mean:
Screenshot 2025-03-23 183618
Also here is where I print the Key:

	promptInstance.PromptHidden:Once(function()
		local key = CustomProximity:FindFirstChild("Key")
		print(key)
		interactButton.Visible = false
		clone:Destroy()
		if CustomProximity then
			CustomProximity:Destroy()
		end
	end)
end)

Here is another video showing this issue:


As you can see in the video, when I look away from the prompt, it prints “Key found”. However when I look back and try to trigger the prompt it says no key found.

Ok this is really confusing i have no idea why its doing this sorry

1 Like

Ok that’s fine, but this issue is persistent. Should I report this as a bug?

1 Like

So I have done some testing, and it seems it’s not the CustomProximity script. Even when I set it to the normal prompt (style: default) it still doesn’t work.

Oh my gosh. I’m so stupid. The problem was that I renamed the tool to “ElectricalKey” and the door open script said “Key”. Bruh.

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