How can I delete the player character?

I have a problem.

I am attempting to make a game, where you do not have a character (OpenTTD, Planet Coaster) and I am trying to delete the charcter. But it deletes the whole workspace!

-- This script runs in StarterCharacterScripts.
script.Parent:Destroy()
8 Likes

I mean im not sure why it’s deleting the baseplate but when you do delete the character it does spit out a couple errors.

Instead, I’d recommend you hide the character either by making it fully transparent or placing it in another part of the map and then create a custom camera

Although you can continue with your idea, but I ain’t sure why it’s deleting the baseplate

3 Likes

WAIT! Never mind, you’re not calling the .new function on Vector3.

You’re doing:

Vector3(num, num, num)

When it should be:

Vector3.new(num, num, num)

In the console ofc

Hence why it’s erroring “Attempt to call a table value” because you put parenthesis after the Vector3 constructor which is a table and NOT a method

3 Likes

I did the Vector3.new thingy btw later. Its just me forgetting things to add to the code.

4 Likes

So… I mean the Workspace is still there from what is seems.

2 Likes

I am also trying to lower the data the game needs to load.

2 Likes

I meant that it kind of reseted it? Like you do a factory reset on a pc, that happens with the workspace. The baseplate you are seeing is made with the console later on.

2 Likes

Ah, maybe instead of doing script.Parent:Destroy() you could explicitly define the Character and THEN destroy it Character:Destroy() maybe explicitly defining it will work. Who knows til you try it?

2 Likes

The same result

local Character = script.Parent
Character:Destroy()
1 Like

Ah well that is basically doing the same thing as the previous code. What I meant it “hardcode” define it like:

local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
Character:Destroy()

Like defining the character (I know the script is in the Character but maybe the script’s parent changes to the Workspace or something like that).

1 Like

The script is Legacy, there is no LocalPlayer.

2 Likes

Hm maybe set Archivable to false for all of the stuff in your baseplate

1 Like

Just make sure there’s a humanoid under the parent, then delete.

1 Like

That doesn’t work. Archivable just means something won’t be saved, it doesn’t mean something can’t be deleted… (Unless I haven’t been educated)

3 Likes

To delete your player’s character, you need to set the Archivable to true, and then you can delete it or just do Character:ClearAllChildren().

1 Like

Oh, always thought it meant it couldn’t be archived or deleted / gettin rid of

1 Like

Tried deleting the Humanoid before deleting the whole character.
The only thing I can say after that, it did the same + spamming in output.

1 Like

2 Likes

Maybe just make the character transparent instead or do so from a LocalScript

1 Like
local Client = game.Players.LocalPlayer
local Character = Client.Character or Client.CharacterAdded:Wait()

Character.Archivable = true
Character:Destroy()

-- Or you can do

Character:ClearAllChildren()
1 Like