Hello there, i need to know if i can make something where when a player leaves it will wait(1) until the player actually leaves. On the players screen the it will look like they already left but in the back-end they are waiting 1 second.
It would help if you explained what you are trying to accomplish by doing that.
im trying to remove a players name from a text button but when i leave it errors and says i am nil bc i already left.
Thanks, that helps. Adding a wait(1) is the wrong way to fix this problem. Can you post the code you currently have?
local PlayerWhoLeft = Player
Whats the point of deleting something out of a player who is leaving. If he leaves, everything inside is destroyed for he is disconnecting from the server.
I second @maturegotit’s point. I don’t understand why you would want to do this.
In any case, try just removing the WaitForChild calls. You don’t need them in this case, since you’re calling this function from the server.
If the following errors, please copy and paste the exact error you see – in fact, this may be impossible to do.
game.Players.PlayerRemoving:Connect(function(player) player.PlayerGui.ModerationCore.GUI.BanFrame.UserName.ScrollingFrame.TextButton:Destroy() end)
Actually, he should use a remote event to notify everyone he left and remove that textbutton from every player screens. @ThoseNamesAreGood
– Server Script
local Event = game.ReplicatedStorage.EVENTNAME game.Players.PlayerRemoving:Connect(function(player) Event:FireAllClients(player.Name) end
– Local Script
local Event = game:GetService("ReplicatedStorage").EVENTNAME local Player = game.Players.LocalPlayer Event.OnClientEvent:Connect(function(playerName) Player.PlayerGui.GUINAME:FindFirstChild(playerName):Destroy() end
That’s just an example so, apply changes to make it work.
Well, you wouldn’t really need a remote event, since the PlayerRemoving event already notifies the server when a player leaves.
Also, is that your goal, @ThoseNamesAreGood? Are you trying to remove the TextButton from all players’ screens?
Yea, i want to remove it from all players screen even though im the only person who could see the GUI.