Hello.
I am making an ordering system, and am having trouble.
This is my script to detect if the player is in the group and is the minimum rank.

this works fine when the staff member clicks the cash register screen and puts an order through, printing the numbers 1, 2 and 3.
However, if the staff member wants to submit another order, they go and click the screen, and the servingUI does not show. Only numbers 1 and 2 are printed out, so I know it has to be something to do with the if not player.PlayerGui:FindFirstChild(“ServingScreen”) then line.
I have done a search through the PlayerGUI and the ServingScreen GUI is not in the playerGUI, so why would this work the first time, but not any times after that, even when the serving GUI is not in the PlayerGUI?
Please help.
Thank you.
FindFirstChild will return the child if the child is in else will return nil.
So the ServingScreen at the first time is not in the playerGui so it return nil, but in the if statement you put a not, so it equal to true.
I the second time the ServingScreen is already in the playerGui so it return the ServingScreen object, but in the if statement you put a not, so it equal to false.
Its not in the playerGUI the second time, because it gets removed once the order is completed. That is why I am confused because it is not in the PlayerGUI the second time, but it won’t work…
When I did the first order, I searched the explorer and you can see that the serving screen is in the PlayerGUI:

I sent the order.
I tried it a second time and did a search in the explorer and nothing came up, as it is not in the playerGUI…

yet it still will not show?
I think I found your problem.
if not player.PlayerGui:FindFirstChild("ServingScreen") then
print("3")
servingUI:Clone().Parent = player.PlayerGui
end
end
end)
With the informations I got I can think that the problem is when you check if the playergui already have in it the “ServingScreen”. I would say to dobule check what happens when you close the gui. If you just put it non visible or enabled false then, you should change it to :Destroy()
Hope this helped, let me know!
Yes it does get destroyed.

This is why its confusing me because it seriously does not exist in PlayerGUI the second time, yet will not work…

Is this code in a Local Script or a Script?
Same with the code you had displayed here

Local Script or a Script?
First one is a Script.
Second is local Script.
3 0 c h a r s
That would be the issue, The original code (Checked on server) checks to see if the UI is in your PlayerGui. Technically speaking your ScreenGui is deleted although only on Client. Perhaps while your sending your Event you can destroy the UI on Server half or just have both scripts done through Client.
2 Likes