So, in my game, I have a part where the player custom creates their character before starting the game. I need a way to store this into a data store because there is a "Load option" .I need the data store so that you can click the load button and get you're currency and character the same as when you left. Here are the options of the character & their code (just incase you need it!)
** Faces**
game.ReplicatedStorage.Events.FaceEvent4.OnServerEvent:Connect(function(plr) local char = plr.Character if char:findFirstChild("Humanoid") then char.Head.face.Texture = "http://www.roblox.com/asset/?id=324583433" end end)
Clothing (both pants & shirts!)
game.ReplicatedStorage.Events.ShirtEvent2.OnServerEvent:Connect(function(plr) local char = plr.Character -- Getting Character char:findFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=3605712285" -- Getting Shirt Template ID end)
** Skin Color**
game.ReplicatedStorage.Events.ColorEvent2.OnServerEvent:Connect(function(plr) -- getting on server event (ColorEvent1, ColorEvent 2 ect) local button = game.StarterGui.CustomizeChar.Frame1.SkinColor2 -- Getting skin changing button local q = BrickColor.new("Brown") -- Color Of Skin local char = plr.Character char.Head.BrickColor = q -- Getting each part of the body to chnage to q (Desierd Color of Skin) char.UpperTorso.BrickColor = q char.LowerTorso.BrickColor = q char["RightLowerArm"].BrickColor = q char["LeftLowerArm"].BrickColor = q char["RightUpperArm"].BrickColor = q char["LeftUpperArm"].BrickColor = q char["LeftLowerLeg"].BrickColor = q char["RightLowerLeg"].BrickColor = q char["RightUpperLeg"].BrickColor = q char["LeftUpperLeg"].BrickColor = q char["RightFoot"].BrickColor = q char["LeftFoot"].BrickColor = q char["RightHand"].BrickColor = q char["LeftHand"].BrickColor = q end)
** & Finally Hair **
game.ReplicatedStorage.Events.HairEvent1.OnServerEvent:Connect(function(plr) local Storage = game.ReplicatedStorage.Hair.Hair1 local char = plr.Character -- Getting Character if char:findFirstChild("Humanoid") then local Folder = char.Head.Hair -- Getting Hair Folder Folder:ClearAllChildren() local Head = char.Head -- Getting Head local New_Hair = Storage:Clone() -- Cloning Hair New_Hair.Parent = Folder -- 115 through 121 is welding the hair to the body New_Hair.Position = Head.Position local Weld = Instance.new("Weld") Weld.Parent = New_Hair Weld.Part0,Weld.Part1 = Head, New_Hair Weld.C0 = CFrame.new(0,0.6,0) Weld.C1 = Head.HairAttachment.CFrame end
(I put the code just incase you needed it)
I looked every where and can't find a way to save these into a number or something and then save that in the data store. If you could help figure this out that would be really helpful. All I need is just a way to store this into a data store. If you have any suggestions on changing the code for one of the customizations that would also be helpful!
Thank you in advance
acuaro
I believe that you can save it straight in there, and if not, put it in an object value. I know that it's possible as I've saved weapons like that. For SkinColor, just save the color in a Color3 value. You can save it all in a dictionary like so
local saves = { 'Hair' = --get hair instance here 'SkinColor' = --get color3 value of skin etc... } --perform save actions
I hope this helps, if you have any questions or problems involving my answer, just comment below.