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
01 | script.Parent.ButtonA.MouseButton 1 Click: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 + Vector 3. new( 0 , 5 , 0 )) |
08 | Player.Character = NewChar |
09 | NewChar.Parent = game.Workspace |
10 | 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.
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
01 | script.Parent.ButtonA.MouseButton 1 Click: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 + Vector 3. new( 0 , 5 , 0 )) |
10 | Player.Character = NewChar |
11 | NewChar.Parent = game.Workspace |
12 | 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!
try making it a while true do loop, (but remember, put a wait() in there or it will break!)