Character Customization Help

Hi So I followed This video and made a character customization system It works as intended although for some reason whenever i or in general any new player joins the game their avatar is without clothes or any accessories just the face. How can i fix this issue ? I want the starter character that i put in starter player to show up and then they can open the editor to edit there character as they want to.

Heres The Video I Followed:

Heres The Model That I modified to fit my game needs:

(I didnt modify any scripts just the gui and the items that the player can equip)

1 Like

the script removes all the players accessories when joining in the loadavatar function

So should i delete that part of the script?

1 Like

not the whole function but the part the destroys the players accessories

i tried that before , the character shows up but is unable to equip the items like shirts pants hats etc

1 Like

because it already wearing the players accessories

1 Like

can you send the script here ?

i meant the starter character does show up but when open the editor to put on items it dosent equip them , like the starter character is wearing a black tshirt for example i open the editor and choose a red one and click confirm , the character is still wearing the black tshirt it dosent get updated

1 Like

sure the orginal or the one with the function removed

Heres the original unedited script:

local items = game.ReplicatedStorage:WaitForChild(“CharacterItems”)
local re = game.ReplicatedStorage:WaitForChild(“CharacterCreatorRE”)

local dss = game:GetService(“DataStoreService”)
local ds = dss:GetDataStore(“DATAsss”)

–Function to save data
function saveData(player)

local currentItems = {}

for i, item in pairs(player.CurrentItems:GetChildren()) do
	table.insert(currentItems, item.Name)
end

ds:SetAsync(player.UserId, currentItems)

end

function loadAvatar(player)
local currentItems = player.CurrentItems
local character = player.Character or player.CharacterAdded:Wait()

for i, child in pairs(character:GetChildren()) do
	if child:IsA("Shirt") or child:IsA("Pants") or child:IsA("Accessory") then
		child:Destroy()
	end
end

for i, item in pairs(currentItems:GetChildren()) do
	if items:FindFirstChild(item.Name, true) then
		
		if item:IsA("Shirt") then
			item:Clone().Parent = character
		elseif item:IsA("Pants") then
			item:Clone().Parent = character
		elseif item:IsA("Accessory") then
			character.Humanoid:AddAccessory(item:Clone())
		end
	end
end

end

–Load player with last saved items
game.Players.PlayerAdded:Connect(function(player)

local currentItems = Instance.new("Folder", player)
currentItems.Name = "CurrentItems"

player.CharacterAdded:Connect(function(character)
	loadAvatar(player)
end)

local data = ds:GetAsync(player.UserId) or {}

for i, itemName in pairs(data) do
	if items:FindFirstChild(itemName, true) then
		local itemType = items:FindFirstChild(itemName, true):FindFirstChildOfClass("Shirt") or items:FindFirstChild(itemName, true):FindFirstChildOfClass("Pants") or items:FindFirstChild(itemName, true)
		itemType:Clone().Parent = currentItems
	end
end
loadAvatar(player)

end)

–Save items currently equipped by user
game.Players.PlayerRemoving:Connect(saveData)
game:BindToClose(function()
for i, player in pairs(game.Players:GetPlayers()) do
saveData(player)
end
end)

–Equip new items
re.OnServerEvent:Connect(function(player, itemsList)

if itemsList and player.Character then
	
	for i, child in pairs(player.Character:GetChildren()) do
		if child:IsA("Shirt") or child:IsA("Pants") or child:IsA("Accessory") then
			child:Destroy()
		end
	end
	
	player.CurrentItems:ClearAllChildren()
	
	for i, item in pairs(itemsList) do
		if items:FindFirstChild(item, true) then
			
			local newItem = items:FindFirstChild(item, true):Clone()
			
			if newItem:IsA("Shirt") then
				if player.Character:FindFirstChildOfClass("Shirt") then
					if player.CurrentItems:FindFirstChild(player.Character:FindFirstChildOfClass("Shirt").Name) then
						player.CurrentItems[player.Character:FindFirstChildOfClass("Shirt").Name]:Destroy()
					end
					player.Character:FindFirstChildOfClass("Shirt"):Destroy()
				end
				
				newItem.Parent = player.Character
				
			elseif newItem:IsA("Pants") then
				if player.Character:FindFirstChildOfClass("Pants") then
					if player.CurrentItems:FindFirstChild(player.Character:FindFirstChildOfClass("Pants").Name) then
						player.CurrentItems[player.Character:FindFirstChildOfClass("Pants").Name]:Destroy()
					end
					player.Character:FindFirstChildOfClass("Pants"):Destroy()
				end
				
				newItem.Parent = player.Character
				
			elseif newItem:IsA("Accessory") then
				player.Character.Humanoid:AddAccessory(newItem)
			end
			
			newItem:Clone().Parent = player.CurrentItems
		end
	end
end

end)

1 Like

this part destroys all player accessories

and this part add the currentitems to the player character

did you remove this part ?
weird interesting text because of a weirder limit

give me a min to test it

ill let you know if any issues

1 Like

Extremely Sorry for the late response i tested it and it works the character is able to equip the items but when the player rejoins they no longer wear it
Let me make it clear with an example
Like the Starter character wore black tshirt and blue jeans
He edited it and made his new character with A hat , red tshirt and black pants

Lets say the player left and rejoined , the hat is chose is still there but his clothing is no longer the one he selected like the red tshirt and black pants instead it is back to black tshirt and blue jeans and they have to open it to equip it again

This was an exampke btw how its happening

1 Like

no problem i am also late :sweat_smile:, check if it saves and load the accessories correctly , print the loaded data