How to save custom character if the player dies?

local player = game.Players.LocalPlayer
local chara = player.Character
local hum = chara:WaitForChild(“Humanoid”)
local runvalue = chara:FindFirstChild(“run?”)

script.Parent.clothings.Done.MouseButton1Click:Connect(function()
script.Parent.clothings.Visible = false
runvalue.Value = true
hum.WalkSpeed = 17
end)

ive heard people used values or something like that to save it but i still dont get what that meant,also that small script is a local script when the player clicks the button to finish custom

You could try to save the clothing/accessories in values to a DataStore (e.g, Green Hair = 1, Blue Hair = 2) It would be long and tedious but definitely possible.
And make sure to update it every time the player saves it.

1 Like

yeah but is there like a way to save it while the player is in the game but when the player leaves it doesn’t save?

I have a morph system where the morph is a model. Whenever a players morphs it saves the morph name in a seperate module script so that whenever the player dies it finds the saved morphs and rewelds it onto the player.

You can probably do something similar to this.

2 Likes

oki so i did some searching and i found the value they used and its a object value

Sure, you can approach it this way. However, I would recommend that you look into serialisation of objects. The idea behind serialisation is to turn an object’s physical property data into parsable data that can then be saved into a data store - in your case, you would serialise character data into a table and then save it into a data store in string format (JSONEncode; https://create.roblox.com/docs/reference/engine/classes/HttpService#JSONEncode). This method works too if you just want to keep character data without saving it - just use the serialised data to construct your character!

1 Like

ill try if i can understand, in the meantime ill keep this post open until i find a answer

ok so ive been thinking that a remote event can be send to server when the player clicks finish and a datastore save it i guess…

1 Like

oki now im just thinking about make it so when the player dies it just saves by a serverscriptserivce script

Honestly, creating value objects under the Player object or creating attributes on the Player object is the best choice, you can reassign all the properties to the attributes or value objects when the Character respawns, if you want to make the data persist between player sessions then you should use DataStoreService.

alrighty i try too do that i guess

i would just copy the players character and save that somewhere with the players user id as the name, then when you detect the player dieing reload the saved character on the player.

So disable the reset button when in character editing and make it so the user has to press a confirm button, and upon pressing that button you copy the players character to a spot where you can save it.