Having issues with welds and players that become ghosts

Hello,

I’m having an issue with Welds. Let’s say we have a scenario where there are 2 Players.

[Player2] is attached through a weld to [Player1].
[Player2] dies but on their screen it breaks [Player 1's] character too.
[Player1] still is alive on their screen and can move, [Player2] can’t see the other player but they are there like a ghost.

This is all on the server.

View Code
function PiggyHandler:BothPlayerAgreePiggy(player2, action, player1)
	if action == "PiggyRequest" then
		local LoadedPiggyBack = player1.Character.Humanoid:LoadAnimation(PiggyBack)

		local Constraint = Instance.new("Weld")
		Constraint.Name = "PiggyWeld"
		Constraint.Parent = player1.Character.UpperTorso
		Constraint.Part0 = player1.Character.UpperTorso
		Constraint.Part1 = player2.Character.UpperTorso
		Constraint.C0 = CFrame.new(0, -2.2, -0.5)

		local player1Pos = player1.Character.UpperTorso
		local player2Pos = player2.Character.UpperTorso
		
		player1.Character.Humanoid.PlatformStand = true
		player1.Character.Humanoid.Sit = true

		LoadedPiggyBack:Play()
		for i, v in pairs(player1.Character:GetDescendants()) do
			if v:IsA("BasePart") then
				v.Massless = true
			end
		end
		
		player1.Character.Humanoid.Died:Connect(function()
			for _, welds in pairs(player1.Character.UpperTorso:GetChildren()) do
				if welds:IsA("Weld") and welds.Name == "PiggyWeld" then
					welds:Destroy()
				end
			end
		end)
	end
end

1 Like

I don,t understand it is it a gilch i can,t tell

Solved by @diawus ‎‎‎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎

1 Like