Players dont go back into the game.Players

hello i am trying to make a script on a client that puts a player into nil and bring back it after a second, though, when i do that they dont appear back.
i tried to search for it but never found anything
code:

local Player = plr
Player.Parent = nil
task.wait(1)
Player.Parent = game:GetService("Players")
1 Like

Wouldn’t putting the player in nil kick them or something?

I mean it feels like something would be wrong if you move the player out of game.Players at all, so wouldn’t it be even more problematic in nil?

why would you need to put it in nil anyways???

1 Like

Yeah I tried and it gets you kicked with the message: “Player has been removed from DataModel”

1 Like

Adding on to this: Player leaving leads to the player object being completely deleted, so that means that theres absolutely no way you can move it again as it literally doesn’t exist anymore.

Yeah, you can’t if you run the code server-sided.

1 Like

im trying it on the client and also player is the second player

Why are you trying to kick and again bring the player, that’s just not possible.

Maybe you want to despawn a player’s character and load again?

1 Like

It doesn’t matter if you run it client-sided or server-sided, you can’t change the parent of a player and not get them kicked. However, you can change the parent of a player character. Maybe you wanted to do that?

when i try to do the code on client on all players expect for ONE and thats the gui owner they dissapear BUT dont get kicked and they still can chat, but trying to undo it they dont go back into Players service

So let me get this straight, you parent every other player nil from a different player’s perspective. If so, yes, they would be able to chat because you only removed them on that player’s side, not the server side. But if you try to parent the local player as nil, then you do get kicked.

i want to make them GO back into the service but they wont go back and it often breaks stuff because ONLY player can see ONLY himself but others as SPIRITS who chat.

so is it now possible to bring back players, is there a hackish way to falsely delete players and put them back? i just need it for my game

Do you just want to delete them off the player list and Roblox GUI (esc)?

yeah, i remove players so people wont see them, but how would i hide players off the list especcially the main menu and disable their chat? and then undo it later after a second

I don’t know how to really bring them back, but this may work. Try making your own player list delete the player, and when you want to bring the player back add them to that list using GUI.

1 Like

To mute them check out this topic: How to make a mute command? - #3 by Extrenious

Lol, I wasn’t aware you could kick the player that way, what’s even more interesting is that you can stack it on top of calling kick but not vice versa:

game.Players.PlayerAdded:Connect(function(player)
	player:Kick()
	task.wait()
	player:Destroy()
end)

Also if task.wait() is commented out the behavior changes, instead of getting:

You were kicked from this experience:
Player has been removed from the DataModel

you get:

You were kicked from this experience:
You were kicked from this experience: You have been kicked from the game

Also, the first version(with task.wait()) also causes a small lag spike between the 2 messages and doesn’t load the game at all, were the second version loads the game even tho the player gets kicked.

you literally cannot bring them back from nil, in programming nil is non existent so your just removing them from the game

try removing their character or something by doing Player.Character

Just a quick correction, if you parent an Instance to nil, that doesn’t necessarily mean that it can’t be brought back; Instances parented to nil will only be garbage collected once there are no more references to it

In this case however, the engine automatically kicks the player once you remove the Player Instance

2 Likes

Yeah, I forgot about that. I said that because before running that code, it said it was marked for deletion. Thank you for correcting me.