Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i set players character (Read Description)?

Asked by 3 years ago
Edited 3 years ago

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.

0
Please let me know if theres a way to fix it. RemsFriend -24 — 3y
0
Explain why you're doing this MarkedTomato 810 — 3y
0
Wdym, i literally said its for a project of mine RemsFriend -24 — 3y
0
It might not work with a localscript AlexanderYar 788 — 3y
View all comments (5 more)
0
It might not work with a localscript AlexanderYar 788 — 3y
0
Ok ill try using a serverscript RemsFriend -24 — 3y
0
serverscript does not work either RemsFriend -24 — 3y
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! JesseSong 3916 — 3y
0
also line 11 isn't needed JesseSong 3916 — 3y

Answer this question