Object:Clone() not working

Code:

script.Parent.Triggered:Connect(function(player)
   local c = game:GetService("ServerStorage").GUIs:WaitForChild("MissionsPrompt"):Clone()
   c.Parent = player.PlayerGui
   c.Script.Enabled = true
   print(c.Parent)
end)

For some reason, I cannot see the ScreenGui. When I run the print, it says 'PlayerGui', yet I do not see it there.

Obviously, this is a ServerScript (via ProximityPrompt)

Have you made sure that WaitForChild is actually returning? It will wait forever if the child is not there.

It definitely is as the PRINT works and I am getting no other output

Is the gui Enabled and are its children all Visible?

yes
thingthingthingthingthing11

Have you checked that player.PlayerGui is not nil before using it to set the parent?

well, it is printing so I assume it is not nil…

either way, I just printed player.Name and it returned correctly.

c.Parent = player.PlayerGui is perfectly legal even if PlayerGui is nil at the time, it will not error. You should probably use WaitForChild() here as well just to be sure.

Just tried that, it did not work.

You’ll have to run it and check what’s going on with the GUI after it gets inserted in Explorer.

1 Like

The name of this instance sounds like it’s a frame.

local screengui = Instance.new('ScreenGui',player.PlayerGui)

local c = game:GetService("ServerStorage").GUIs:WaitForChild("MissionsPrompt"):Clone()
c.Parent = screengui

Nope. It does not. I checked.
30

it is 100% a screengui
i do not know why this is happening

1 Like

You are checking player gui right? And not starter gui? If you are, then sorry I don’t know how else I can help you.

yeah, thats what im saying. IDK what the prob is

1 Like

Still cannot find the issue here. So sad

While testing, check your playerGui if it actually has the UI, if it does it could only mean that your gui isnt enabled or nothing in it is visible.

I cannot believe I just made this mistake. I had a script in it preventing players from going too far from the part-to-interact so it kept destroying. hah, found the issue.

Thanks!

1 Like

No problem, but please set my post as the solution since it helped you to know the problem, have a nice day!