Hello there, I have this script here which checks for a GUI when the .PlayerRemoving has fired:
game.Players.PlayerRemoving:Connect(function(Player)
if Player.PlayerGui.MenuUI:FindFirstChild("PlayerLobby") then
end
end)
Though it says PlayerGui is not a valid member of Player meaning the Player is already nil or the Player has left.
Is there a different way of doing this? If so a reply would be appreciated.
Any help is appreciated, Thanks.
1 Like
I’m confused why this would need to be used. If the player isn’t in the game, what would you possibly need this for?
Okay but why
By the time the Player already leaves like you said, defining its PlayerGui
& MenuUI
variables will already be nil
since their client is closed
I’m just wondering why you’re doing this, since you’re literally doing nothing changing the GUI when the Player leaves
@Jackscarlett @DataAspect , This isn’t all of my code. Its just a base for what I need
But is there any logical reason why you would need to get the player’s playergui after they have left? I don’t see a single use case for this.
1 Like
Basically, I’m setting a Image to nil if their UserId matches with the ImageId
But they’ve already left, so they wouldn’t see the change.
Well I’m also setting other players Images which are still in the server to nil too.
Could you just use Player.UserId? No idea why you would need to get the playergui.
1 Like
To answer this:
More than likely in the way you’re doing it, no
You’re attempting to make GUI changes by the time the Player leaves, which will result as a nil
value
If for some reason you really want to do this, use DataStores
instead to detect when a player begins to leave & save certain values & detect the changes that way
I need to get the Image in a frame and compare it with the UserId, Not just the UserId…
1 Like
So there is no way to do this other than using DataStores?
1 Like
If you really need an image id that bad, just send the image id to the server when it changes.
1 Like
Well, my choice would be to use DataStores
You can also use RemoteEvents
if you want everyone to see the Player that left, using FireAllClients()
with sending the Player’s UserId
1 Like