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

0

Please let me know if theres a way to fix it.

0

Explain why you're doing this

0

Wdym, i literally said its for a project of mine

0

It might not work with a localscript

0

It might not work with a localscript

0

Ok ill try using a serverscript

0

serverscript does not work either

0

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!

0

also line 11 isn't needed