You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to make a custom proximity prompt.
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:
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:
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.
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’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.
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?
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.
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:
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)
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.
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.