Having trouble deleting a cloned characters motor6D

Im trying to make a client-sided ragdoll system, so far everything works but my code is having trouble deleting a cloned characters Motor6D’s

The following is the Ragdoll code

local function ragdoll(char)
	char:WaitForChild("Humanoid").AutoRotate = false
	for _, part in char:GetDescendants() do
		if part:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local a1 = Instance.new("Attachment")
			local a2 = Instance.new("Attachment")
			a1.Parent = part.Part0
			a2.Parent = part.Part1
			socket.Parent = part.Parent
			socket.Attachment0 = a1
			socket.Attachment1 = a2
			a1.CFrame = part.c0
			a2.CFrame = part.c1
			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true
			socket.MaxFrictionTorque = 0
			print("FoundMotor6d")
			part:Destroy()
		end
	end
	
	char.HumanoidRootPart:ApplyImpulse(Vector3.new(math.random(-RAGDOLL_MAGNITUDE, RAGDOLL_MAGNITUDE), math.random(RAGDOLL_MAGNITUDE), math.random(-RAGDOLL_MAGNITUDE, RAGDOLL_MAGNITUDE)))
end

When I clone the character using the following code

Remotes.Ragdoll.OnClientEvent:Connect(function(plr)
	if plr == game.Players.LocalPlayer then
		ragdoll(character)
		return
	end
	if plr.Character then
		plr.Character.Archivable = true
	else
		return
	end
	local ClonedCharacter = plr.Character:Clone()
	ClonedCharacter.Parent = workspace
	ClonedCharacter:PivotTo(plr.Character.PrimaryPart.CFrame)
	plr.Character:Destroy()
	ragdoll(ClonedCharacter)
end)

The module prints that it found 16 Motor6D and then launches the player but the player doesn’t end up ragdolling and is instead stiff.

Looking into the ragdoll model the motor6D’s are still there and so are the new ball socket constraints.
I tried adding a wait in between the character being cloned and the ragdoll function being called and the system worked perfectly except for there is a noticeable 1 second delay.

Now I bet I could solve this issue by cloning every character once a player respawns and sort of caching it or just setting a fixed delay and kinda hoping the system will work 100% of the time.
But I wanted to know if there was an easier way to solve this, or if there is maybe a property I can enable.

Are all the scripts running on the client?

All the provided code is running on the client.

Try cloning the character on the server.

If you really want it fully client sided then I suggest sending a remote to the server to set the specific parts with network ownership, part:SetNetworkOwner(plr)

Well the character is made on the client so the server has no idea it even exists, and the character gets flung around just fine, it’s just the Motor6D won’t disappear.

Hold up, why are you even cloning the character in the first place?

Alright it all makes sense now, what I see is that your trying to clone a dead character. Dead characters dont have Motor6Ds. If you want to keep the Motor6Ds beyond death then you should turn off a property on the humanoid called “BreakJointsOnDeath”

  1. If i clone the character on the server then the individual clients cant fling it and it will be choppy for the players (essentially making it a serversided system)

  2. If I don’t clone the character then same as before the client doesn’t have network ownership and the system wont work.

  3. No I don’t want the motor6D’s the issue is they are still there and you can see in the ragdoll() function that i actually delete them.

If you clone the character on the client its practically non existant on the server which means nobody can see it or interact with it. Plus, this kind of issue sounds more like a client and server issue. Try changing some certain things to interact with the server I guess?

Thats the point. The server tells all the clients that they need to create a ragdoll for this character, the clients individually do that, server doesn’t have to do physics for ragdolls but clients do making the experience much smoother and nicer looking on the client.

Thats why its called a client-sided system

Still havent solved this issue…

@Dlbsp1983 figured it out, instead of destroying the Motor6D’s I set the Enabled property to false.

6 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.