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

Why does my GUI only enable the first time a character spawns?

Asked by 7 years ago
Edited 7 years ago

Is it bad to ask a question the day after you already asked a previous one? I don't know if it is but here's the question.

Right now I'm currently trying to make a GUI disable upon death and enable when a player respawns. The way I'm trying to make it work is by having a script in the ServerScriptService check when a player joins, create an event for that player and fire it whenever said player spawns:

local RStorage = game:GetService("ReplicatedStorage")
local PlayerFolder = RStorage.PlayerFolder

game.Players.PlayerAdded:connect(function(player)
    local pN = player.Name
    local NewPlrEvent = Instance.new("RemoteEvent", PlayerFolder)
    NewPlrEvent.Name = pN
    player.CharacterAdded:connect(function(character)
        print (pN.. "has spawned.")
        NewPlrEvent:FireAllClients()
    end)
end)

The players local script is supposed to check whenever the event is fired:

-- finding the new event
local PlayerFolder = RStorage.PlayerFolder
local ourFolder = PlayerFolder:WaitForChild("Explosivesguy2")

function renewGUI()
    MainGUI.Enabled = true
    print ("Gui is up and running!")
end

ourFolder.OnClientEvent:Connect(renewGUI)

For the prints, the following is printed: (When the player first joins) Explosivesguy2has spawned. GUI is up and running! (When the player dies and then respawns) Explosivesguy2has spawned.

I've been looking online for about 30 minutes and couldn't find anything to fix it. Please respond and explain what you did, I'm new to scripting and would love to hear new solutions and ways to script.

Quick Edit: I don't want the property for the GUI to reset on spawn, I want the GUI to go back to where the player last was before it was disabled.

0
As a sidenote, Creating a remoteevent is not good practice. Just create it in studio. All the events you need to tell when a player dies and spawns can be listened to by the client and don't need a server script to tell them. You also don't tell us what is not working, so we can't really help right now lukeb50 631 — 7y
0
Yes. Repeating a question is not allowed. But since I do not see this copied from any of your other questions, I will not moderate it.. hiimgoodpack 2009 — 7y
0
As to what hiimgoodpack said, we dont care if you ask frequently as long as its a new question and you have already tried yourself. Spamming us with your every little problem that you tried nothing to fix is not accepted on the other hand lukeb50 631 — 7y
0
ok, cool. Also, yeah I don't think I actually asked the question.. Explosivesguy2 20 — 7y
View all comments (3 more)
0
wait, no the question was in the title. Explosivesguy2 20 — 7y
0
Simply go to the ScreenGui and click ResetOnSpawn and make it false. Albino_Albino 0 — 7y
0
Just clone the GUI when the player dies and when he respawns, place it back in there. Boom! User#18043 95 — 7y

Answer this question