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?
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.
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.
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,
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.
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?