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

How do I stop a GUI from reseting when a player resets?

Asked by
NecoBoss 194
10 years ago

So I have a textbutton that uses on click to give 1 point every 3 seconds:

function onClick()
    if game.Players.LocalPlayer.leaderstats.Score.Value >= 100 then
    script.Parent.Visible = false
    while true do
        game.Players.LocalPlayer.leaderstats.Score.Value = game.Players.LocalPlayer.leaderstats.Score.Value + 1
        local str =  game.Players.LocalPlayer.leaderstats.Score.Value
        local str1 = "Your income: "
        game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Cashincome.Text = str1..str

wait(3) 
    end
    end
end
script.Parent.MouseButton1Click:connect(onClick)

This works great but when I reset it stops the while loop and makes the GUI visible again. How do I stop it from doing this?

2 answers

Log in to vote
4
Answered by
Lacryma 548 Moderation Voter
10 years ago

You might need this:

game:GetService("StarterGui").ResetPlayerGuiOnSpawn = false

You can do this in studio too, so it is disabled by default.

0
Thank you. I can now make progress again. NecoBoss 194 — 10y
Ad
Log in to vote
3
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

Using this property of StarterGui.

I'm not sure if the HealthGUI problem still applies. I'll look into it and edit the page. EDIT: It does not.

Answer this question