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.