The question that i'm about to ask is pretty weird so I understand if you dont get it.
Basically a few days ago, I started working on a new project of mine named "RePlayer" and i've encountered an issue that I don't honestly know how to explain.
The issue: Whenever I set LocalPlayer's parent to nil and then set it's parent back to game.Players, I cannot change the Character.
What the console prints out: "Character cannot be changed as Player (player's name) is being removed."
The code:
--It's in a LocalScript btw
local Player = game:GetService("Players").LocalPlayer
local Character = game:GetService("Players").LocalPlayer.Character
game:GetService("RunService").Heartbeat:Wait()
local function RePlayer(Amount)
Player.Parent = nil -- This sets players parent to nil, also sets player's character to nil.
wait(Amount)
Player.Parent = game:GetService("Players")
Player.Character = Character -- The part that errors
end
RePlayer(1)
Once again, if you do not understand the question, it's alright.

9 comments
Please let me know if theres a way to fix it.
Explain why you're doing this
Wdym, i literally said its for a project of mine
It might not work with a localscript
It might not work with a localscript
Ok ill try using a serverscript
serverscript does not work either
The reason it throws you with that error is because you set the parent to nil. Just remove line 9, and you should be fine!
also line 11 isn't needed