Arm rotation not working after death

As the title says, the rotation just doesn’t work after death
Vid: Untitled - Clipped with Medal.tv

Code: (Not mine)

local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local PlayerMouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character:WaitForChild("Head")
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Torso = Character:WaitForChild("Torso")
local Neck = Torso:WaitForChild("Neck")
local LeftSh = Torso:WaitForChild("Left Shoulder")
local RightSh = Torso:WaitForChild("Right Shoulder")
local Larm = Character:WaitForChild("Left Arm")
local Rarm = Character:WaitForChild("Right Arm")


local ShoulderRightOriginC0 = RightSh.C0
local ShoulderLeftOriginC0 = LeftSh.C0
local NeckOriginC0 = Neck.C0

Neck.MaxVelocity = 1/3

local lerpamount = 0.1
RunService.RenderStepped:Connect(function() 
	local CameraCFrame = Camera.CoordinateFrame
	if Character:FindFirstChild("Torso") and Character:FindFirstChild("Head") then
		if Humanoid.Health ~= 0 then
			local TorsoLookVector = Torso.CFrame.lookVector
			local HeadPosition = Head.CFrame.p
			if Neck then
				if Camera.CameraSubject:IsDescendantOf(Character) or Camera.CameraSubject:IsDescendantOf(Player) then
					local Point = PlayerMouse.Hit.p

					local DistanceRight = (Rarm.CFrame.p - Point).magnitude / 1.5
					local DifferenceRight = Rarm.CFrame.Y - Point.Y
					local goalRightCFrame = CFrame.Angles(-(math.atan(DifferenceRight / DistanceRight) * 1), (((Rarm.Position - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0)

					local DistanceLeft = (Larm.CFrame.p - Point).magnitude / 1.5
					local DifferenceLeft = Larm.CFrame.Y - Point.Y
					local goalLeftCFrame = CFrame.Angles(-(math.atan(DifferenceLeft / DistanceLeft) * 1), (((Larm.Position - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0)

					local startedtime = os.clock()
					local tbl = {
						[RightSh] = {["C0"] =  RightSh.C0:lerp(goalRightCFrame*ShoulderRightOriginC0, 1 / 1).Rotation + ShoulderRightOriginC0.Position},
						[LeftSh] = {["C0"] =  LeftSh.C0:lerp(goalLeftCFrame*ShoulderLeftOriginC0, 1 / 1).Rotation + ShoulderLeftOriginC0.Position}
					}

					for i,v in pairs(tbl) do
						local Deltatime = os.clock() - startedtime
						local lerpp = (1-lerpamount)^(Deltatime)
						local dir = i.C0:lerp(v["C0"], lerpp)
						game.ReplicatedStorage.FetchLocal:FireServer(PlayerMouse.Hit.Position,dir, i)
					end
					print("ya")
				end
			end
		end
	end	
end)
1 Like

First off, where is the script parented? It looks like it should be in StarterCharacterScripts since those are reloaded when the character’s added. If it’s in StarterPlayerScripts, I would move it to StarterCharacterScripts. If it absolutely needs to be in the player scripts, you can just connect the values of the joints (i.e. LeftSh, Neck, etc.) and refresh their values when the character is added again

1 Like

StarterCharacterScripts
aaaaaaa

1 Like
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local PlayerMouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character:WaitForChild("Head")
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Torso = Character:WaitForChild("Torso")
local Neck = Torso:WaitForChild("Neck")
local LeftSh = Torso:WaitForChild("Left Shoulder")
local RightSh = Torso:WaitForChild("Right Shoulder")
local Larm = Character:WaitForChild("Left Arm")
local Rarm = Character:WaitForChild("Right Arm")


local ShoulderRightOriginC0 = RightSh.C0
local ShoulderLeftOriginC0 = LeftSh.C0
local NeckOriginC0 = Neck.C0

Neck.MaxVelocity = 1/3

local lerpamount = 0.1
RunService.RenderStepped:Connect(function() 
	local CameraCFrame = Camera.CoordinateFrame
	if Character:FindFirstChild("Torso") and Character:FindFirstChild("Head") then
                print("Head and Torso")
		if Humanoid.Health > 0 then
                        print("Alive")
			local TorsoLookVector = Torso.CFrame.lookVector
			local HeadPosition = Head.CFrame.p
			if Neck then
                                print("Neck")
				if Camera.CameraSubject:IsDescendantOf(Character) or Camera.CameraSubject:IsDescendantOf(Player) then
					local Point = PlayerMouse.Hit.p

					local DistanceRight = (Rarm.CFrame.p - Point).magnitude / 1.5
					local DifferenceRight = Rarm.CFrame.Y - Point.Y
					local goalRightCFrame = CFrame.Angles(-(math.atan(DifferenceRight / DistanceRight) * 1), (((Rarm.Position - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0)

					local DistanceLeft = (Larm.CFrame.p - Point).magnitude / 1.5
					local DifferenceLeft = Larm.CFrame.Y - Point.Y
					local goalLeftCFrame = CFrame.Angles(-(math.atan(DifferenceLeft / DistanceLeft) * 1), (((Larm.Position - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0)

					local startedtime = os.clock()
					local tbl = {
						[RightSh] = {["C0"] =  RightSh.C0:lerp(goalRightCFrame*ShoulderRightOriginC0, 1 / 1).Rotation + ShoulderRightOriginC0.Position},
						[LeftSh] = {["C0"] =  LeftSh.C0:lerp(goalLeftCFrame*ShoulderLeftOriginC0, 1 / 1).Rotation + ShoulderLeftOriginC0.Position}
					}

					for i,v in pairs(tbl) do
						local Deltatime = os.clock() - startedtime
						local lerpp = (1-lerpamount)^(Deltatime)
						local dir = i.C0:lerp(v["C0"], lerpp)
						game.ReplicatedStorage.FetchLocal:FireServer(PlayerMouse.Hit.Position,dir, i)
					end
					print("updated")
				end
			end
		end
	end	
end)

The print statements are spaced oddly because I’m writing this post on my phone

It looks like some of your loop isn’t running. By looking at what prints and what doesn’t, you can see what’s causing the problem. If nothing prints, your RenderStepped loop isn’t running or head/Torso is missing from character.

Prints everything but after I die updated doesn’t get printed anymore

That means that workspace.Camera.CameraSubject isn’t the player’s humanoid or anything attached to the player. The if statement around it isn’t really useful unless you’re trying to make a spectating system where you’re switching it. You can either remove it entirely or replace it with a different condition (i.e. is there a tool parented to character? yes, then proceed, no, then do nothing)

By the way, what are you trying to achieve with the arm movement?

Didn’t think the solution was that easy lol, I’m making a hellmet typa game

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