Hello! Recently I have started adding some ‘Character Customisation’ features into my game, but I’d like to save what the player has created. How would I achieve this?
My Customisation Script:
local selectionframe = script.Parent.SelectionFrame
local selectionframes = script.Parent.SelectionFrames
local ifviewing = script.Parent.IfViewing
local clone = game.Workspace:WaitForChild("".. game.Players.LocalPlayer.Name .. "'s_Clone")
--------------------------------------------------------------------------------------------------
--Hats
local Hats = selectionframes.HatSelectionFrame
Hats.Hat1.MouseButton1Click:Connect(function()
if Hats.Hat1.IfWearing.Value == false then
Hats.Hat1.IfWearing.Value = true
if clone:FindFirstChild("Hat2") then
clone.Hat2:Destroy()
end
if clone:FindFirstChild("Hat3") then
clone.Hat3:Destroy()
end
local hat = game.ReplicatedStorage.Clothes.Hats.Hat1:Clone()
hat.Parent = clone
local weld = Instance.new("Weld")
weld.Parent = clone.Head
weld.Name = "HeadWeld"
weld.Part0 = hat.Handle
weld.Part1 = clone.Head
weld.C0 = CFrame.new(0, -.7, 0)
else
Hats.Hat1.IfWearing.Value = false
if clone:FindFirstChild("Hat1") then
clone.Hat1:Destroy()
end
end
end)
Hats.Hat2.MouseButton1Click:Connect(function()
if Hats.Hat2.IfWearing.Value == false then
Hats.Hat2.IfWearing.Value = true
if clone:FindFirstChild("Hat1") then
clone.Hat1:Destroy()
end
if clone:FindFirstChild("Hat3") then
clone.Hat3:Destroy()
end
local hat = game.ReplicatedStorage.Clothes.Hats.Hat2:Clone()
hat.Parent = clone
local weld = Instance.new("Weld")
weld.Parent = clone.Head
weld.Name = "HeadWeld"
weld.Part0 = hat.Handle
weld.Part1 = clone.Head
weld.C0 = CFrame.new(-.05, -.5, 0)
else
Hats.Hat2.IfWearing.Value = false
if clone:FindFirstChild("Hat2") then
clone.Hat2:Destroy()
end
end
end)
Hats.Hat3.MouseButton1Click:Connect(function()
if Hats.Hat3.IfWearing.Value == false then
Hats.Hat3.IfWearing.Value = true
if clone:FindFirstChild("Hat1") then
clone.Hat1:Destroy()
end
if clone:FindFirstChild("Hat2") then
clone.Hat2:Destroy()
end
local hat = game.ReplicatedStorage.Clothes.Hats.Hat3:Clone()
hat.Parent = clone
local weld = Instance.new("Weld")
weld.Parent = clone.Head
weld.Name = "HeadWeld"
weld.Part0 = hat.Handle
weld.Part1 = clone.Head
weld.C0 = CFrame.new(0, -.2, 0)
else
Hats.Hat3.IfWearing.Value = false
if clone:FindFirstChild("Hat3") then
clone.Hat3:Destroy()
end
end
end)
--------------------------------------------------------------------------------------------------
--Shirts
local Shirts = selectionframes.ShirtSelectionFrame
Shirts.Shirt1.MouseButton1Click:Connect(function()
if Shirts.Shirt1.IfWearing.Value == false then
Shirts.Shirt1.IfWearing.Value = true
if clone:FindFirstChildWhichIsA("Shirt") then
shirt = clone:FindFirstChildWhichIsA("Shirt")
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=1174846799"
else
shirt = Instance.new("Shirt")
shirt.Parent = clone
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=1174846799"
end
else
if game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Shirt") then
shirt.ShirtTemplate = game.Players.LocalPlayer.Character.Shirt.ShirtTemplate
Shirts.Shirt1.IfWearing.Value = false
else
shirt:Destroy()
Shirts.Shirt1.IfWearing.Value = false
end
end
end)
Shirts.Shirt2.MouseButton1Click:Connect(function()
if Shirts.Shirt2.IfWearing.Value == false then
Shirts.Shirt2.IfWearing.Value = true
if clone:FindFirstChildWhichIsA("Shirt") then
shirt = clone:FindFirstChildWhichIsA("Shirt")
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=4800855967"
else
shirt = Instance.new("Shirt")
shirt.Parent = clone
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=4800855967"
end
else
if game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Shirt") then
shirt.ShirtTemplate = game.Players.LocalPlayer.Character.Shirt.ShirtTemplate
Shirts.Shirt2.IfWearing.Value = false
else
shirt:Destroy()
Shirts.Shirt2.IfWearing.Value = false
end
end
end)
Shirts.Shirt3.MouseButton1Click:Connect(function()
if Shirts.Shirt3.IfWearing.Value == false then
Shirts.Shirt3.IfWearing.Value = true
if clone:FindFirstChildWhichIsA("Shirt") then
shirt = clone:FindFirstChildWhichIsA("Shirt")
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=3769979025"
else
shirt = Instance.new("Shirt")
shirt.Parent = clone
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=3769979025"
end
else
if game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Shirt") then
shirt.ShirtTemplate = game.Players.LocalPlayer.Character.Shirt.ShirtTemplate
Shirts.Shirt3.IfWearing.Value = false
else
shirt:Destroy()
Shirts.Shirt3.IfWearing.Value = false
end
end
end)
--------------------------------------------------------------------------------------------------
--Pants
local Pants = selectionframes.PantsSelectionFrame
Pants.Pants1.MouseButton1Click:Connect(function()
if Pants.Pants1.IfWearing.Value == false then
Pants.Pants1.IfWearing.Value = true
if clone:FindFirstChildWhichIsA("Pants") then
pant = clone:FindFirstChildWhichIsA("Pants")
pant.PantsTemplate = "http://www.roblox.com/asset/?id=129458425"
else
pant = Instance.new("Pants")
pant.Parent = clone
pant.PantsTemplate = "http://www.roblox.com/asset/?id=129458425"
end
else
if game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Pants") then
pant.PantsTemplate = game.Players.LocalPlayer.Character.Pants.PantsTemplate
Pants.Pants1.IfWearing.Value = false
else
pant:Destroy()
Pants.Pants1.IfWearing.Value = false
end
end
end)
Pants.Pants2.MouseButton1Click:Connect(function()
if Pants.Pants2.IfWearing.Value == false then
Pants.Pants2.IfWearing.Value = true
if clone:FindFirstChildWhichIsA("Pants") then
pant = clone:FindFirstChildWhichIsA("Pants")
pant.PantsTemplate = "http://www.roblox.com/asset/?id=4767255047"
else
pant = Instance.new("Pants")
pant.Parent = clone
pant.PantsTemplate = "http://www.roblox.com/asset/?id=4767255047"
end
else
if game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Pants") then
pant.PantsTemplate = game.Players.LocalPlayer.Character.Pants.PantsTemplate
Pants.Pants2.IfWearing.Value = false
else
pant:Destroy()
Pants.Pants2.IfWearing.Value = false
end
end
end)
Pants.Pants3.MouseButton1Click:Connect(function()
if Pants.Pants3.IfWearing.Value == false then
Pants.Pants3.IfWearing.Value = true
if clone:FindFirstChildWhichIsA("Pants") then
pant = clone:FindFirstChildWhichIsA("Pants")
pant.PantsTemplate = "http://www.roblox.com/asset/?id=730590583"
else
pant = Instance.new("Pants")
pant.Parent = clone
pant.PantsTemplate = "http://www.roblox.com/asset/?id=730590583"
end
else
if game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Pants") then
pant.PantsTemplate = game.Players.LocalPlayer.Character.Pants.PantsTemplate
Pants.Pants3.IfWearing.Value = false
else
pant:Destroy()
Pants.Pants3.IfWearing.Value = false
end
end
end)
--------------------------------------------------------------------------------------------------
--Backpacks
local Backs = selectionframes.BackSelectionFrame
Backs.Back1.MouseButton1Click:Connect(function()
if Backs.Back1.IfWearing.Value == false then
Backs.Back1.IfWearing.Value = true
if clone:FindFirstChild("Back2") then
clone.Back2:Destroy()
end
if clone:FindFirstChild("Back3") then
clone.Back3:Destroy()
end
local back = game.ReplicatedStorage.Clothes.Back.Back1:Clone()
back.Parent = clone
back.AttachmentRight = Vector3.new(0.5, 0, 0)
local weld = Instance.new("Weld")
weld.Parent = back.Handle
weld.Name = "AccessoryWeld"
weld.Part0 = back.Handle
weld.Part1 = clone.Torso
weld.C0 = CFrame.new(0, 0, -.4)
else
Backs.Back1.IfWearing.Value = false
if clone:FindFirstChild("Back1") then
clone.Back1:Destroy()
end
end
end)
Backs.Back2.MouseButton1Click:Connect(function()
if Backs.Back2.IfWearing.Value == false then
Backs.Back2.IfWearing.Value = true
if clone:FindFirstChild("Back1") then
clone.Back1:Destroy()
end
if clone:FindFirstChild("Back3") then
clone.Back3:Destroy()
end
local back = game.ReplicatedStorage.Clothes.Back.Back2:Clone()
back.Parent = clone
back.AttachmentRight = Vector3.new(0.5, 0, 0)
local weld = Instance.new("Weld")
weld.Parent = back.Handle
weld.Name = "AccessoryWeld"
weld.Part0 = back.Handle
weld.Part1 = clone.Torso
weld.C0 = CFrame.new(0, -.3, -.4)
else
Backs.Back2.IfWearing.Value = false
if clone:FindFirstChild("Back2") then
clone.Back2:Destroy()
end
end
end)
Backs.Back3.MouseButton1Click:Connect(function()
if Backs.Back3.IfWearing.Value == false then
Backs.Back3.IfWearing.Value = true
if clone:FindFirstChild("Back1") then
clone.Back1:Destroy()
end
if clone:FindFirstChild("Back2") then
clone.Back2:Destroy()
end
local back = game.ReplicatedStorage.Clothes.Back.Back3:Clone()
back.Parent = clone
back.AttachmentRight = Vector3.new(0.5, 0, 0)
local weld = Instance.new("Weld")
weld.Parent = back.Handle
weld.Name = "AccessoryWeld"
weld.Part0 = back.Handle
weld.Part1 = clone.Torso
weld.C0 = CFrame.new(0, -.3, -.9)
else
Backs.Back3.IfWearing.Value = false
if clone:FindFirstChild("Back3") then
clone.Back3:Destroy()
end
end
end)
Would I save the model and put it into database perhaps? (I don’t really understand saving data yet so I may be wrong.)