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

PlayerGui resets after player dies. How can I prevent this?

Asked by 4 years ago

I made a playerGui that stores the amount of gold a player currently has after buying a citizen. I read that setting ResetPlayerGuiOnSpawn = false would prevent this. I put this script into both a Local and regular script and the playerGui still resets after they die. I use print(guiReset) and it comes back with false.

wait(3) -- Waits for the player to load before starting the script. Will change to a WaitForChild later

while wait(0.5) do

    for i,v in pairs (game.Players:GetPlayers()) do -- GetPlayers return the players in the game. V refers to any objects in the players tab
        wait(1)
        guiReset = game:GetService("StarterGui").ResetPlayerGuiOnSpawn
        guiReset = false
        print(guiReset)
        goldGui = v.PlayerGui.resources.resourcesFrame.Gold
        goldGui.Text = goldGui.amount.Value

    end
end
0
Not a full answer, but my suggestion is to keep ResetPlayerGuiOnSpawn to true but have a :Destroy() script for when the player resets Raccoonyz 1092 — 4y
0
What would I destroy? If I destroy the gui when the player dies, the new one will still respawn and reset. if I destroy the new one after they die, they wont have a gui RAM_BN0 0 — 4y
0
I have an idea, cant test it yet but the idea is that anytime their gold value is updated it sends the amount to a table. In the script towards the bottom I will put in some code that tells the script, send their gold value to TableA. Then, send it back to their gold value. RAM_BN0 0 — 4y
0
I gave it a try and it didn't work. Though I'm still new to LUA but improving. If I ever find a way to make the playerGui not reset after death I will post it RAM_BN0 0 — 4y

Answer this question