When my character respawns, it duplicates the gui of the player

Hello there,

I need help with my game. So I have AutoCharacterLoads off because I don’t want the character to load when they join the game and I have a script where when it clicks on a button, it spawns the player and although it works, the gui gets duplicated. I even turned on ResetOnSpawn and that didn’t work. Can somebody please help me? Thank you.

3 Likes

You should turn off the ResetOnSpawn option, or if it didnt work, i recommend sending here the script or try to search for problem in the script.

See, the gui originally had ResetOnSpawn off but, that didn’t work. Do you think that issue is caused by a script or is that normal?

To be honest, I dont know if the script caused the problem. You should try to check or search for problems. Maybe there is thing that turns that option on, and you dont even know about it. Try to search for the problem, or send the script here i will help you. :slightly_smiling_face:

Ok, I will search for problems. Thank you.

1 Like

Ok, so unfortunately I searched about a problem like this and there were no results and also, I have a script that duplicates the GUI and gives it to the player when they join so I disabled it to see if that’s what’s causing the issue and when I disabled it and started the game, I just dragged all of the GUIs into the PlayerGui folder and when I clicked on the button that respawns the character, it still clones the GUI. I even searched the term “StarterGui” in the find all/replace all and there were some results but, they didn’t have to do with cloning the GUI and giving it to the player (except the script that I have disabled)

I found something really strange. I wanted to test out if this issue is coming from my game or not so I created a baseplate game to test it and I have two scripts: a LocalScript that detects when a player clicks a button and sends a signal via a RemoteEvent, and a server-side script that spawns the character when it receives the signal. After testing, the GUI still duplicates and this proves that this issue is not coming from my game, it’s probably coming from the scripts that I’m using to spawn the player in. If you’d like, I can share the scripts I’m using to spawn the player to see if that might be causing the issue. Thank you!

Sure, you can send the script and i can help you with that.

I discovered that when a player spawns in Roblox, the game automatically duplicates everything in the StarterGui into the player’s PlayerGui. Unfortunately, this is something that is impossible to stop as there is no way to prevent this from happening. The only way to solve this problem is that I moved all of the ScreenGuis into a folder outside of StarterGui. This way when a player spawns, nothing is copied from StarterGui by default. Instead, I use a script to copy the contents of that folder into the player’s PlayerGui when they join the game.

Just make a check in a script like if script.parent.name = player.name then do run the script

what do you mean by that? can you at least give me an example?

Hi
This is indeed due to CharacterAutoLoads.

If I remember correctly the way I prevent this is to manually clone StarterGui on join (since player doesn’t get a character at first). Then I listen to ChildAdded on the PlayerGui. If a child is added with a name that already exists in the PlayerGui, remove that newly added child to prevent the duplicate.

Keep in mind this has the added restriction of unique ScreenGui names in StarterGui. For me this is needed anyways since my gui scripts aren’t located in StarterGui.

Another solution is to not place your gui in StarterGui I found this slightly annoying to work with though since you can’t work on the gui in studio’s edit mode without manually copying and removing it again from StarterGui.

1 Like

Yeah, i recommend doing some kind of server script that will be runned when player connects to the game, and copies the GUI to the PlayerGui, thats the thing that should help or you did already.

Like u add a code in your script checking to ensure if the parent or ancestor is a player, then run the script, or u can check if script.parent == StarterPlayer then return. This way will get rid of StarterPlayer