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

Why does a LocalScript function not add the GUI on Reset but does on Start Up?

Asked by
Kami_Yo 72
5 years ago

So I found out that the PlayerGui and StaterGui is Client side so I made a Remote Event to access them from the Client. But for some reason it only works when the player starts the game up, but not when they reset. I was told that I had this error before because the GUI is on the client side, but even when using a RemoteEvent on the client it still doesn't work.

Here is the remote event: It is inside a LocalScript that is a child of the GUI and the GUI is in StarterGui.

ReplicatedStorage.GetQuestManager.OnClientEvent:Connect(function(questId, questData)
    print("GET QUEST MANAGER RAN")

    local guiContainer = script.Parent:WaitForChild("Container")
    local currentQuestsContainer = guiContainer:WaitForChild("CurrentQuests")

    local questTag = CreateTag(questId,questData)
    questTag.Parent = currentQuestsContainer

end)

Now on startup I have a function that runs and calls the Remote Event and it works. And on Reset I run the exact same function that calls the Remote Event, which it DOES call it since I still get the print statement, except nothing happens and the questTag is not added to the CurrentQuestsContainer. And I honestly have no idea why.

The only difference is that on Reset, when I call the function it is within these two:

game.Players.PlayerAdded:Connect(function(player) 
    player.CharacterAppearanceLoaded:Connect(function(char)

While on startup it is only within:

game.Players.PlayerAdded:Connect(function(player)

Does anybody know why it isn't working? The print statement runs, so why doesn't the rest work?

0
Please do Gui.ResetOnSpawn = false (Upvote if this helped) danglt 185 — 5y
0
Where do I put that? In the LocalScript with the ReplicatedStorage.GetQuestManager.OnClientEvent:Connect(function(questId, questData)? Kami_Yo 72 — 5y
0
Thank you for the help. You made me aware that the GUI resets and that there is a way to stop it from resetting. I wish I could upvote you, but I don't have enough points for it. All I did was add: "game:GetService("StarterGui").ResetPlayerGuiOnSpawn = false" and it worked Kami_Yo 72 — 5y
0
[ BASED OF THE QUESTION NAME ] Open properties, then search "Reset", untick the box. WideSteal321 773 — 5y

Answer this question