Ragdoll script buggy

  1. What is the issue?
    So right now when you ragdoll and hit the ground your character goes crazy trying to face in the same direction as the camera.

  2. What do you want to achieve?
    I want the character to ignore the camera while ragdolled. But I also want to be able to look around while ragdolled, so setting the CameraType to Scriptable is hard.

  3. What solutions have you tried so far?
    Looked on dev hub, and assistant. Didn’t help much.
    I’m not new to scripting with Roblox, but I’m pretty new to cameras and stuff like that.

SCRIPT:

local Torso: Part = script.Parent.Torso
local RagdollingTime = 0
local Humanoid: Humanoid = script.Parent:WaitForChild("Humanoid")
script.Parent.Ragdoll.Event:Connect(function(Power, Vel, RagTime) --RagTime is optional
	if script.Parent.HealthStamina:GetAttribute("Invincible") == false then
		Humanoid.RequiresNeck = false
		script.Parent.HealthStamina:SetAttribute("Ragdolled", true)
		Humanoid.JumpPower = 0
		
		wait()
		
		Humanoid.PlatformStand = true		
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Physics, true)
		
		for _, Object in ipairs(Torso:GetChildren()) do
			if Object:IsA("Motor6D") then
				Object.Enabled = false
			end
		end
		
		for _, Object in ipairs(script.Parent:GetChildren()) do
			if Object:IsA("BasePart") then
				Object.CollisionGroup = "Ragdolled" -- Ragdolled can't collide with each other
			end
		end
		
		script.Parent.InvisLeftLeg.CanCollide = true
		script.Parent.InvisLeftArm.CanCollide = true
		script.Parent.InvisRightLeg.CanCollide = true
		script.Parent.InvisRightArm.CanCollide = true
		script.Parent.InvisHead.CanCollide = true
		
		script.Parent.LocalRagdoll:FireClient(game.Players[script.Parent.Name], Power, Vel)
		
		if RagTime == nil then
			RagdollingTime = math.round(Power / 40) + 60
		else
			RagdollingTime = RagTime
		end
		
	end
end)

game["Run Service"].Stepped:Connect(function(Time, Delta)
	if Torso:FindFirstChild("Right Shoulder") then		
		if RagdollingTime <= 0 and Torso["Right Shoulder"].Enabled == false then
			Humanoid.RequiresNeck = true
			Humanoid.PlatformStand = false
			Humanoid:SetStateEnabled(Enum.HumanoidStateType.Physics, false)

			for _, Object in ipairs(Torso:GetChildren()) do
				if Object:IsA("Motor6D") then
					Object.Enabled = true
				end
			end
			
			for _, Object in ipairs(script.Parent:GetChildren()) do
				if Object:IsA("BasePart") then
					Object.CollisionGroup = "Characters"
				end
			end

			script.Parent.InvisLeftLeg.CanCollide = false
			script.Parent.InvisLeftArm.CanCollide = false
			script.Parent.InvisRightLeg.CanCollide = false
			script.Parent.InvisRightArm.CanCollide = false
			script.Parent.InvisHead.CanCollide = false
			
			local HumanoidRootPart = script.Parent.HumanoidRootPart
			
			HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.CFrame.Position.X, HumanoidRootPart.CFrame.Position.Y + 4, HumanoidRootPart.CFrame.Position.Z) * CFrame.fromOrientation(0, 0, 0)
			
			script.Parent.HealthStamina:SetAttribute("Ragdolled", false)
		end
	end
	
	RagdollingTime -= Delta * 60
end)
1 Like