I just made this temporary DataStore that I wanted to try out for my character creator I'm trying to make. The thing is that the data of the player exists, and it even printed out the right skin color, and when I try to change the skin color through a for i loop, I had prints set up to say that it was working and changing the color, and it was. It even printed out the changed skin color. The problem is that the default roblox avatar or something like that is overriding the changed skin color. Can anyone help me?

My server script in ServerScriptService:

local DataStore = game:GetService("DataStoreService"):GetDataStore("CharacterGUI")

local function saveSkin(plr)
	local key = "plr-"..plr.UserId
	local CharData = DataStore:GetAsync(key)
	
	local folder = Instance.new("Folder")
	folder.Parent = plr
	folder.Name = "SkinData"
	
	local skinc = Instance.new("StringValue")
	skinc.Parent = folder
	skinc.Name = "SkinColor"
	
	if CharData then
		skinc.Value = CharData[1]
		print("Data found")
		print(skinc.Value)
		for i,v in pairs (CharData) do
			print(v)
		end
		local skincolor = CharData[1]
		for i, v in pairs (CharData) do
				
				local char = plr.Character
				for i, v in pairs (char:GetChildren()) do
					if v.ClassName == "Part" then
						print("Color changing")
						v.BrickColor = BrickColor.new(CharData[1])
						print(v.BrickColor)
				end
			end
		end
		
	elseif not CharData then
		local skincolors = {"Brown","Light orange"}
		skinc.Value = skincolors[1]
		DataStore:SetAsync(key,skincolors)
		print(skinc.Value)
		print("Data not existant")
	end
end
game.Players.PlayerAdded:Connect(function(plr)
	
	saveSkin(plr)
	local char = plr.Character
	local plrinplrs = game.Players:FindFirstChild(plr.Name)
	if plrinplrs ~= nil then
		
		game.Players[plr.Name].CanLoadCharacterAppearance = false
		game.Players[plr.Name]:ClearCharacterAppearance()

	end
end)


2 comments

0

use :IsA("BasePart") instead of checking the classname

0

I solved this by just disabling the LoadCharacterAppearance in the StarterPlayer in the Explorer