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

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

Asked by 5 years ago

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

01script.Parent.ButtonA.MouseButton1Click:Connect(function()
02    local Player = game.Players:WaitForChild("bostaffmanbulgaria1")
03    local OldCharacter = game.Workspace[Player.Name]:Clone()
04    OldCharacter.Parent = script
05    local NewChar = game.ReplicatedStorage.Dummy:Clone()
06    NewChar.Name = Player.Name
07    NewChar:SetPrimaryPartCFrame(game.Workspace[Player.Name]:FindFirstChild("HumanoidRootPart").CFrame + Vector3.new(0, 5, 0))
08    Player.Character = NewChar
09    NewChar.Parent = game.Workspace
10end)

**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

Log in to vote
1
Answered by 5 years ago

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

01script.Parent.ButtonA.MouseButton1Click:Connect(function()
02    local Player = game.Players:WaitForChild("bostaffmanbulgaria1")
03    local Character = workspace[Player.Name]
04    Character.Archivable = true
05    local OldCharacter = Character:Clone()
06    OldCharacter.Parent = script
07    local NewChar = game.ReplicatedStorage.Dummy:Clone()
08    NewChar.Name = Player.Name
09    NewChar:SetPrimaryPartCFrame(game.Workspace[Player.Name]:FindFirstChild("HumanoidRootPart").CFrame + Vector3.new(0, 5, 0))
10    Player.Character = NewChar
11    NewChar.Parent = game.Workspace
12end)

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!

0
Thanks a lot. I never thought of the Archivable property to be disabled. bostaffmanbulgaria1 89 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

Answer this question