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

A part that gives a GUI even after the player resets?

Asked by 5 years ago

I have a morph base and I use a script to apply both the morph and a GUI to the player when the part is touched. If the player were to reset, having used the morph or not, they will still get the morph's parts and appearance back, but not the GUI.

I use this script to give the GUI using debounce, and it does give the GUI, but only if the player has not reset during the active game.

local part = script.Parent

local debounce = false

part.Touched:Connect(function(hit)
    if not debounce then
        debounce = true

        local ptt = game.Players:playerFromCharacter(hit.Parent)
        if ptt == nil then return end 
        local wfp = script.Parent:findFirstChild("ScreenGui"):clone()
        if wfp == nil then return end 
        wfp.Parent = ptt.PlayerGui

        wait(0.5)

        debounce = false
    end
end)

Players testing this have had to rejoin and, in some cases, have the server shut down as the script still wouldn't work after rejoining the active server.

0
You could try setting the Gui's property, "ResetOnSpawn" to false. Stephenthefox 94 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

Hello,

To make a GUI stay after a players death, we can use a property of ScreenGui called ResetOnSpawn. Here's how we'd use it.

(Assuming that the localscript's parent was the ScreenGui.)

ScreenGui = script.Parent
ScreenGui.ResetOnSpawn = false

That's all, it makes sure that everything inside the ScreenGui will stay after the character respawns or dies.

0
Huge thanks to both you and Stephenthefox, I feel incredibly stupid not thinking about this before. Again though, thank you! AureXII 9 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

You can set the ScreenGui's property, "ResetOnSpawn" to false.

When the game ends and you want to remove the gui, you can hook up a remote event and a local script(to delete it)

Answer this question