Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[solved] why is PlayerGui being emptied when player respawns? [closed]

Asked by 9 years ago

so, offline everyhting is working, when i play the game the plaer spawns with all guis, when i reset the player, the player respawns with everything like it's scripted to do. but online when the player respawns i se the guis for a sec and then they disappear, i guess they are being destroyed. this seems like something new to me, because i'm pretty sure it was all working before. the script i'm using to load the guis is like this

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
while not player.Character do wait() end

local g = game.ServerStorage.gui:Clone()
g.Parent = player.PlayerGui

end)
end)

is there ANY reason why g wouldn't be cloned into playergui after they reset or die?

3
I would think the CharacterAdded event fires before the PlayerGui gets cleared and reloaded. I could be wrong though. Have a repeat wait() until player:FindFirstChild('PlayerGui') after line 3. M39a9am3R 3210 — 9y
0
thx. this seems to fix it! OMG! what a fing relief. thought i was losing my mind. johnnygadget 50 — 9y

Locked by MessorAdmin, User#5978, and chess123mate

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

4 answers

Log in to vote
0
Answered by
Hexcede 52
9 years ago

It needs to be in the starter gui or you need to clone it in every time. I would like it if roblox added in a gui backpack like the normal backpack but they havent. :)

0
thx, you're right, except i actually need this to be cloned into playergui manually because of technical reasons, so having it in startergui isn't an option. johnnygadget 50 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Put g in game.StarterGui, when a player dies it resets into startergui. Just adding it to playegui wont make it permenment

0
You know I already said that right? Wow some people just sometimes like to copy or do it without even realizing it. :3 Hexcede 52 — 9y
0
Chill, I didn't copy you. We both posted 5 minutes ago. User#5978 25 — 9y
0
+Mine was first I just editted mine. User#5978 25 — 9y
Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
9 years ago

There is a property of PlayerGui called ResetPlayerGuiOnSpawn that holds a bool value telling the game whether you want PlayerGui's descendants to be removed or not. It defaults to true but if you set this to false all of the gui's inside of PlayerGui will not be altered.

If you only want a couple of GUIs to not be deleted, you have the option of either letting them all delete and cloning the ones you want back into PlayerGui or setting ResetPlayerGuiOnSpawn to false and using either the Died or CharacterAdded event to remove the unwanted GUIs.

In terms of your script, the Error might be coming from you variable 'g' itself. You forgot to put the '()' on the end of Clone.

local g = game.ServerStorage.gui:Clone()
0
i just quickly typed that as an example. but shouldn't it be cloning the g and placing it in playergui everytime the players characteradded is fired? like everytime the player resets and they respawn shouldn't it run through that part of the script again? johnnygadget 50 — 9y
0
Yeah it should BlackJPI 2658 — 9y
Log in to vote
0
Answered by 9 years ago

how to fix this is create a folder named starter store that in lighting or storage create a for loop that loops the children of starter and moves them to player gui in starter player