Camera stays in the position where the player died previously

Hi Developers! :wave:

I’ve recently stumbled upon a serious problem in my game. I inserted a ragdoll after death script, which partly broke the game process I think

How does the bug occur?

It doesn't appear every time when the player dies, maybe 1 in 7 deaths. The character is present, I can even move it and use my weapons, so only the camera is messed up.

The script which maybe the source of this problem

it is located in ServerScriptService
game:GetService("Players").PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").BreakJointsOnDeath = false
		character:WaitForChild("Humanoid").Died:Connect(function()
			for i, v in pairs(character:GetDescendants()) do
				if v:IsA("Motor6D") then
					local attachment0, attachment1 = Instance.new("Attachment"), Instance.new("Attachment")

					attachment0.CFrame = v.C0
					attachment1.CFrame = v.C1

					attachment0.Parent = v.Part0
					attachment1.Parent = v.Part1

					local constraint = Instance.new("BallSocketConstraint")

					constraint.Attachment0 = attachment0
					constraint.Attachment1 = attachment1

					constraint.Parent = v.Part0

					v:Destroy()
				end
			end

			character:WaitForChild("HumanoidRootPart").CanCollide = false

		end)
	end)
end)

I would appreciate any help provided! :hidere:

2 Likes

probably a studio bug or some sort but it cant be that script.

1 Like

Insert local script in starter character:

if not script.Parent:FindFirstChildOfClass("Humanoid") then repeat task.wait(0.001) until script.Parent:FindFirstChildOfClass("Humanoid") end
workspace.CurrentCamera.CameraSubject = script.Parent:FindFirstChildOfClass("Humanoid")

I hope this helps!

1 Like

I’ll try to use it tomorrow, I really want this to work.

I’m sorry, but I can’t really find if it is the solution for the problem right now. Maybe on this weekend I’ll finally define.

But I think this pretty much fixes the bug in solo gameplay, so thank you in advance! :blush:

1 Like

By the way, if it won’t work, than try to fire remote event when ragdoll script ends and on the other script set player’s camera subject to their character’s humanoid

1 Like