Help making a player spawn with their customized creation

So, I have the basic Character Customization system down. It’s connected to a data store so what they choose will save but how would I make it, so they spawn as the character they created? The script I have so far is below

local DSS = game:GetService("DataStoreService"):GetDataStore("DemonSlayer")

local ServerScriptService = game:GetService("ServerScriptService")

local hNext = game.ReplicatedStorage:WaitForChild("hNext")
local hBack = game.ReplicatedStorage:WaitForChild("hBack")


	--Hair

	hNext.OnServerEvent:Connect(function(player)		
	print("test")
	
	
	if player:WaitForChild("Data"):WaitForChild("Hair").Value <= 20 then
	
		player:WaitForChild("Data"):WaitForChild("Hair").Value = player:WaitForChild("Data"):WaitForChild("Hair").Value + 1
		
		local HairValue = player.Data.Hair.Value
		local HairObject = game.ServerScriptService.Hair:FindFirstChild("Hair"..tostring(HairValue))
	print(HairObject)
	
	
	
	local HairValue = player.Data.Hair.Value
	local PlayersHair = player.Character:FindFirstChild("Hair"..tostring(HairValue) - 1)
	PlayersHair:Destroy()
	
	
		HairObject:Clone().Parent = player.Character
		
		
	end	
end)
	
	
	
	
	hBack.OnServerEvent:Connect(function(player)		
	print("test")
	
	
	if player:WaitForChild("Data"):WaitForChild("Hair").Value >= 1 then
	
		player:WaitForChild("Data"):WaitForChild("Hair").Value = player:WaitForChild("Data"):WaitForChild("Hair").Value - 1
		
		local HairValue = player.Data.Hair.Value
		local HairObject = game.ServerScriptService.Hair:FindFirstChild("Hair"..tostring(HairValue))
		print(HairObject)
		
		local HairValue = player.Data.Hair.Value
		local PlayersHair = player.Character:FindFirstChild("Hair"..tostring(HairValue) + 1)
		PlayersHair:Destroy()
		
		HairObject:Clone().Parent = player.Character
		
		
	end
	end)


game.ReplicatedStorage.HairColorChange.OnServerEvent:Connect(function(Player)

	local Character = Player.Character
	
	
	local HairColor = Player.Data.HairColor.Value
	
	
	for _, Accessory in pairs(Character:GetChildren()) do	
		if Accessory:IsA("Accessory") then
			local Handle = Accessory:FindFirstChild("Handle")
			-- 	if Handle and Handle:FindFirstChild("HairAttachment") then
			if Handle then
				Handle.Color = HairColor
			end
		end
	end 
end)

1 Like

Nevermind it was a really simple fix! I just looked for the data value then clone the hair once the player loaded

1 Like