Hi! I’m trying to make a GUI Panel for fun, and I want only my friends to get the panel. However, I realized that the Panel does not appear if the player has respawned. The Panel is in ReplicatedStorage, and I am using a Script in ServerScriptService to give the GUI to players.
At first, I did
game.Players.PlayerAdded:Connect(function(plr)
if plr:IsFriendsWith(1363219555) or plr.Name == "alxzile" then
local gui = game.ReplicatedStorage.Panel:Clone()
gui.Parent = plr.PlayerGui
end
end)
For the most part, this worked when the player initially joined the game, but the Panel did not respawn when the player respawned.
Then, I thought that this was because the Panel was getting removed from the PlayerGui when the player died, so I added
plr.CharacterAdded:Connect(function(plr)
This didn’t fix anything and the issue remained the same.
After tons of trial and error, I tried rewriting the script and replacing the Panel. I made the Panel a child of starter gui, and rewrote the script in ServerScriptService to:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
if not plr:IsFriendsWith(1363219555) or plr.Name == "alxzile" then
plr.PlayerGui.Panel:Destroy()
end
end)
end)
This did not work at all. I did not even get the Panel when I joined the game.
Lastly, I thought that the issue was caused by the ResetOnSpawn property glitching out, so I added, to the original script,
for _, v in ipairs(plr.PlayerGui.Panel:GetDescendants()) do
if v:IsA("ScreenGui") or ("TextLabel") or ("TextButton") or ("ImageLabel") then
v.ResetOnSpawn = true
Needless to say, the issue was indeed not caused by the ResetOnSpawn property being weird.
Furthermore, how could I about fixing this issue? I’ve looked through numerous devforum posts, however none of them had a matching issue/solution.
Thanks in advance.