I can't clone a GUI and parent it to the playerGUI with a proximitypromt

Hello developers,
I’m trying to make a GUI clone and be placed into the playerGUI that the player who triggered the proximity prompt.
Here is my script:

script.Parent.Triggered:Connect(function(plr)
local Clone = script.Parent.GasStation:Clone()
Clone.Parent = plr.PlayerGui
end)

Please help me out here. I tried doing this in a server script and a local script. Nothing works.

FYI, you need to use three backticks (`) before and after your code block to format it correctly. The backtick key is next to 1 on most keyboards and requires SHIFT to access it.

Based on what I see in your code, that should work. What does the object structure look like in explorer? Can you post a screenshot of it? What errors are you getting?

That didn’t work. And I’m not getting any errors at all in my explorer about that script at all.

Can you write the code how you would do it, please? It would really help.

I used the referenced code, and it seems to be working for me. I did have a similar issue with using ProximityPrompts where the object was intersecting with other objects. Have you tried turning the ProximityPrompt’s “RequiresLineOfSight” property to false?

The issue could also be with whether the location of the cloned GUI is enabled & on screen.
image

Nevermind. I see that GasStation is a ScreenGui. Half asleep.

That sadly did not work. My proximitypromt is in a huge block.

It is in a screenGUI object. Look here:
image

Your code is the way that I have done it. Something else must be wrong, but I’m not sure what. Does the ProximityPrompt even show up?

Try moving the script and the GasStation ScreenGui object and reparenting them to Part. You will need to make script changes to reflect the new structure and see if that works.

script.Parent.ProximityPrompt
script.Parent.GasStation

I think it could be better to use a Server script for the UI, since I’m assuming you want the player to interact with whatever is in the GasStation ScreenGUI. I just tried changing the script to a LocalScript and it didn’t work either,

I’ll try both of these methods right now.

I tried doing it in a server script and parenting the Prox and the UI to the part but still, it doesn’t work.

You can’t do it from a local script within the workspace. The local script won’t execute because it must have specific locations as an ancestor. You can have a local script inside the ScreenGui object though and use remote events to communicate with the server. I’ve done that before.

That’s not the problem. I tried using a server script.

Have you checked the position of the “GasStation” ScreenGUI object or if the object is enabled?

And there’s still no errors?

Is the ScreenGui enabled and Frame.Visible = true?

1 Like

If you have a local script under the ScreenGui, try adding a print statement to the top of it. If the local script executes when the ScreenGui is parented to PlayerGui, then we know the local script is working. What does PlayerGui look like after the script runs?

Omg, I’m so dumb I had the ScreenGUI not enabled. Ahhh, thank you for the time and help.

That would do it. Don’t feel bad, I’ve done stupid things too…like claiming that you didn’t have a ScreenGui object when you clearly did.

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