Welding Bug in Roblox?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    What I am trying to do is keep the clothing on the player. They are welded to the player in startercharacter.

  2. What is the issue? Include screenshots / videos if possible!
    Our issue is that when a player respawns they loose their clothing and if they do have clothing it seems to be on the client only even though the respawn and stuff is on server.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried all types of things like attachments, weld constraints, welds, manual welds etc. Yeah i looked for some, they kept saying its like a bug with welds.

this is what the startercharacter looks like.
Annotation 2020-02-21 105157

--//Code for Loading Player's Customization Data
local rp = game:GetService("ReplicatedStorage")
local DataRemote = rp:WaitForChild("Data")
local Clothing = rp:WaitForChild("Clothing")

--//Storage of hairs and Races
local Hairs = rp:WaitForChild("Hairs")
local Races = rp:WaitForChild("Races")

--//Colors and stuff
local hairColors = {Color3.fromRGB(79, 79, 79),Color3.fromRGB(0, 0, 0),Color3.fromRGB(255, 255, 255),Color3.fromRGB(255, 0, 0),Color3.fromRGB(0, 0, 255),Color3.fromRGB(255, 255, 0),Color3.fromRGB(255, 102, 0),Color3.fromRGB(128, 0, 128),Color3.fromRGB(0, 255, 0),Color3.fromRGB(128, 0, 0)}
local humanSkins = {Color3.fromRGB(255, 204, 153),Color3.fromRGB(229, 194, 152),Color3.fromRGB(228, 185, 142),Color3.fromRGB(217, 145, 100),Color3.fromRGB(204, 132, 67),Color3.fromRGB(199, 122, 88),Color3.fromRGB(190, 114, 60),Color3.fromRGB(68, 0, 0)}
local demonSkins = {Color3.fromRGB(231, 231, 236),Color3.fromRGB(255, 255, 153),Color3.fromRGB(204, 255, 255),Color3.fromRGB(51, 51, 0),Color3.fromRGB(255, 204, 0),Color3.fromRGB(128, 0, 128),Color3.fromRGB(204, 255, 204),Color3.fromRGB(153, 51, 102),Color3.fromRGB(153, 51, 102),Color3.fromRGB(255, 0, 0)}
local eyeColors = {Color3.fromRGB(0, 0, 0),Color3.fromRGB(255, 0, 0),Color3.fromRGB(204, 255, 255),Color3.fromRGB(255, 255, 0),Color3.fromRGB(255, 0, 255),Color3.fromRGB(0, 128, 128),Color3.fromRGB(153, 51, 0),Color3.fromRGB(255, 153, 204)}

local faces = {
	["Face1"] = {["Eyebrows"] = "rbxassetid://4119806216", ["Eye"] = "rbxassetid://4453008215", ["Face"] = "rbxassetid://4399351941" },
	["Face2"] = {["Eyebrows"] = "rbxassetid://4119859420", ["Eye"] = "rbxassetid://4418208019", ["Face"] = "rbxassetid://4418161782" },
	["Face3"] = {["Eyebrows"] = "rbxassetid://4119859420", ["Eye"] = "rbxassetid://4499969643", ["Face"] = "rbxassetid://4499965807" },
    ["Face4"] = {["Eyebrows"] = "rbxassetid://4119859420", ["Eye"] = "rbxassetid://4459202818", ["Face"] = "rbxassetid://4459186642" },
    ["Face5"] = {["Eyebrows"] = "rbxassetid://4455160018", ["Eye"] = "rbxassetid://4477794185", ["Face"] = "rbxassetid://4477783164" }

}

local Storage = script:WaitForChild("Storage")

game.Players.PlayerAdded:Connect(function(Player)
	DataRemote:FireClient(Player)
	
	Player.CharacterAdded:Connect(function(Character)
		DataRemote:FireClient(Player)
	end)
end)

DataRemote.OnServerEvent:Connect(function(Player,DataToLoad)
	local Character = Player.Character
	
	--//Player Customization Data
	local CustomizationData = Instance.new("Folder",Player)
	CustomizationData.Name = "CustomizationData"
	
	for i, fold in pairs(Storage:GetChildren()) do
		local folder = fold:Clone()
		folder.Parent = CustomizationData
	end
	
	--//Load Data
	for i, fold in pairs(CustomizationData:GetChildren()) do
		for j, data in pairs(fold:GetChildren()) do
			if data:IsA("StringValue") then
				data.Value = DataToLoad[i][j]
			elseif data:IsA("Color3Value") then
				local R
				local G
				local B
				for k=1, 3 do
					if k==1 then
						R = tonumber(DataToLoad[i][j][k])
					elseif k==2 then
						G = tonumber(DataToLoad[i][j][k])
					elseif k==3 then
						B = tonumber(DataToLoad[i][j][k])
					end
				end
				print(R,G,B)
				data.Value = Color3.fromRGB(R,G,B)
			end
		end
	end
	
	local Assets = CustomizationData:WaitForChild("Assets")
	local Colors = CustomizationData:WaitForChild("Colors")
	
	--//Race Handler
	local Race = Assets:FindFirstChild("Race")
	if Race then
		if Race.Value == "Human" then
			--//Making new Character for player to load as
			local newChar = Races.Human:Clone()
			newChar.Name = "StarterCharacter"
			
			--//Removes previous startercharacter
			game.StarterPlayer.StarterCharacter:Destroy()
			
			--//Parents the newChar to StarterCharacter
			newChar.Parent = game.StarterPlayer
			
			--//Reloads Character
			Player:LoadCharacter()
			Character = Player.Character
			
			--//Remove is after character loads to prevent any overlap with other players
			--
			
			--use HSkin
			local skinColor = Colors:FindFirstChild("HSkin")
			if skinColor then
				local r = math.floor(skinColor.Value.r * 255)
				local g = math.floor(skinColor.Value.g * 255)
				local b = math.floor(skinColor.Value.b * 255)
				
				local newColor = Color3.fromRGB(r,g,b)
				for l, m in pairs(Character:GetChildren()) do
					if m:IsA("MeshPart") or m:IsA("Part") then
						m.Color = newColor
					end
				end
				
			end
			
		elseif Race.Value == "Demon" then
			--//Making new Character for player to load as
			local newChar = Races.Demon:Clone()
			newChar.Name = "StarterCharacter"
			
			--//Removes previous startercharacter
			game.StarterPlayer.StarterCharacter:Destroy()
			
			--//Parents the newChar to StarterCharacter
			newChar.Parent = game.StarterPlayer
			
			--//Reloads Character
			Player:LoadCharacter()
			Character = Player.Character
			
			--//Remove is after character loads to prevent any overlap with other players
			--
			
			--use DSkin
			local skinColor = Colors:FindFirstChild("DSkin")
			if skinColor then
				local r = math.floor(skinColor.Value.r * 255)
				local g = math.floor(skinColor.Value.g * 255)
				local b = math.floor(skinColor.Value.b * 255)
				
				local newColor = Color3.fromRGB(r,g,b)
				for l, m in pairs(Character:GetChildren()) do
					if m:IsA("MeshPart") or m:IsA("Part") then
						m.Color = newColor
						--[==[local Horn = m:FindFirstChild("horn")
						if Horn then
							Horn.Color = newColor
						end]==]
					end
				end
				
			end
		end
	end
	
	--//Asset Handler
	for i, v in pairs(Assets:GetChildren()) do
		local Head = Character:FindFirstChild("Head")
		if v.Name == "Hair" then
			local Hair = Hairs:FindFirstChild(v.Value):Clone()
			if Hair then
				--//Removes Preset Hair
				for j,k in pairs(Character:GetChildren()) do
					if string.match(k.Name,"Hair") then
						k:Destroy()
					end
				end
				--//Parents Saved Hair
				Hair.Parent = Character
				local HairColor = Colors:FindFirstChild("HairC")
				if HairColor then
					local r = math.floor(HairColor.Value.r * 255)
					local g = math.floor(HairColor.Value.g * 255)
					local b = math.floor(HairColor.Value.b * 255)
					local newColor = Color3.fromRGB(r,g,b)
					
					Hair.Handle.Color = newColor
					Head.eyebrow.Color3 = newColor
				end
			end
		elseif v.Name == "Face" then
			local Head = Character:FindFirstChild("Head")
			if Head then
				--//Loading Face
				Head.eye.Texture = faces[v.Value]["Eye"]
				Head.eyebrow.Texture = faces[v.Value]["Eyebrows"]
				Head.face.Texture = faces[v.Value]["Face"]
				
				--//Loading Eye Color
				local eyeColor = Colors:FindFirstChild("EyesC")
				if eyeColor then
					local r = math.floor(eyeColor.Value.r * 255)
					local g = math.floor(eyeColor.Value.g * 255)
					local b = math.floor(eyeColor.Value.b * 255)
					
					local newColor = Color3.fromRGB(r,g,b)
					Head.eye.Color3 = newColor
				end
			end
		end
	end
	
	for i, v in pairs(Character:GetChildren()) do
		if v:IsA("Part") or v:IsA("MeshPart") then
			if v.Name == "LowerTorso" then
				local cloth = Clothing:FindFirstChild(v.Name)
				if cloth then
					cloth:Clone()
					cloth.Parent = v
					cloth.LowerTorso.CFrame = v.CFrame
					
					local weld = Instance.new("ManualWeld")
					weld.Part0 = cloth.LowerTorso
					weld.Part1 = v
					weld.C0 = weld.Part0.CFrame:inverse() * weld.Part1.CFrame
					weld.Parent = weld.Part0
				end
			else
				local cloth = Clothing:FindFirstChild(v.Name)
				if cloth then
					cloth:Clone()
					cloth.Parent = v
					cloth.CFrame = v.CFrame
					
					local weld = Instance.new("ManualWeld")
					weld.Part0 = cloth
					weld.Part1 = v
					weld.C0 = weld.Part0.CFrame:inverse() * weld.Part1.CFrame
					weld.Parent = weld.Part0
				end
			end
		end
	end
	
end)

if you have any idea why the clothing doesn’t spawn please let me know, Thanks in advance!

What’s in the clothing folder?

2 Likes

The individual clothing pieces, I thought i could do it that way but still doesnt work either. Annotation 2020-02-21 110846

Alrighty. Let me play around and see what I can do.

1 Like

alrighty, also something to note, the character’s customization stuff still loads and works, just seems the clothing is not.

May I also ask why you’re firing the DataRemote to the Client and then from the Client to the Server?

1 Like

and this is a separate place, like after finishing you teleport to the main game, and then it loads it

soo after they are teleported to the main game, that script fires the client and the client gets the teleport data that was transferred, then sends the data to the server via OnServerEvent and then the server loads up the player’s customization.

Alright it seems to be loading on the server alright, but I am getting the issue with it not doing it upon respawn. Looking into it now.

1 Like

Alright I found the issue.

When morphing the player you did

cloth:Clone()
cloth.Parent = v

which is setting the parent of the original morph model. you should do

newCloth = cloth:Clone()
newCloth.Parent = v
newCloth.CFrame = v.CFrame
						
local weld = Instance.new("Weld")
weld.Part0 = v
weld.Part1 = newCloth
weld.C0 = newCloth.CFrame:toObjectSpace(v.CFrame)
weld.Parent = newCloth
2 Likes

ooooooooo alrighty i’ll try this Thanks for the help I really appreciate it!

1 Like

It WORKSSSSS THANK YOU SOOOOOOOO MUCH MAN HOLY CRAP BEEN TRYING TO FIX THIS FOR THE PAST 2 WEEKS I REALLY APPRECIATE IT! YOU ARE THE BEST!

You’re welcome dude, if you have any other issues I’ll answer them. Anytime.

2 Likes