Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I "respawn" as myself after being morphed to something else?

Hello, I am attempting to respawn my original character to my current one.

What have I done to get to this point? ` - I have created a morph button, changing my character to a model I put in

  • Changed it's name
  • Repositioned it to my old character's CFrame`

-- Scriptwise

script.Parent.ButtonA.MouseButton1Click:Connect(function()
	local Player = game.Players:WaitForChild("bostaffmanbulgaria1")
	local OldCharacter = game.Workspace[Player.Name]:Clone()
	OldCharacter.Parent = script
	local NewChar = game.ReplicatedStorage.Dummy:Clone()
	NewChar.Name = Player.Name
	NewChar:SetPrimaryPartCFrame(game.Workspace[Player.Name]:FindFirstChild("HumanoidRootPart").CFrame + Vector3.new(0, 5, 0))
	Player.Character = NewChar
	NewChar.Parent = game.Workspace
end)

**What I am trying to accomplish? **

I'm trying to revert my old character back in the same way as I morphed it.

What I have done so far?

  • Cloned my old character before any code regarding character change being ran
  • result: ERROR: Players.bostaffmanbulgaria1.PlayerGui.ScreenGui.Script:4: attempt to index nil with 'Parent'

I did **not ** find any information about this in Google.

2 answers

✓ Accepted answer

Characters by default are not archivable. That means you cannot clone them neither save a copy of them if their archivable property is set to false.

To do this you have to set it's Archivable property to true

Character.Archivable = true

Implementing this into your code

script.Parent.ButtonA.MouseButton1Click:Connect(function()
    local Player = game.Players:WaitForChild("bostaffmanbulgaria1")
    local Character = workspace[Player.Name]
    Character.Archivable = true
    local OldCharacter = Character:Clone()
    OldCharacter.Parent = script
    local NewChar = game.ReplicatedStorage.Dummy:Clone()
    NewChar.Name = Player.Name
    NewChar:SetPrimaryPartCFrame(game.Workspace[Player.Name]:FindFirstChild("HumanoidRootPart").CFrame + Vector3.new(0, 5, 0))
    Player.Character = NewChar
    NewChar.Parent = game.Workspace
end)

I also recommend to use FindFirstChild() instead of game.Workspace[Player.Name] and also use workspace instead of game.Workspace

If that answered your question mark it as the answer!

1 comment

0

Thanks a lot. I never thought of the Archivable property to be disabled.

try making it a while true do loop, (but remember, put a wait() in there or it will break!)

This discussion is preserved as it was. New answers, comments, and votes are closed.