Hi, I have this script which rotates your torso to your mouse, but it doesn’t work after dieing, it is in starter character scripts, please help.
local script:
wait()
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local plr = Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local mouse = plr:GetMouse()
local sprint = char.Sprinting
local camera = workspace.CurrentCamera
local debounce = false
local CameraPos = char:WaitForChild("CameraPos")
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://16250185228'
local PlayAnim = char.Humanoid:LoadAnimation(Anim)
local Game = game
local RunService = Game:GetService("RunService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart") or Character:WaitForChild("HumanoidRootPart")
local UserInputService = game:GetService("UserInputService")
UserInputService.MouseDeltaSensitivity = .01
RunService.Heartbeat:Connect(function()
local Time = 0
while true do
if Time > math.deg(math.pi / 12) then break end
local Pivot = CameraPos:GetPivot()
local CF = CFrame.lookAt(Pivot.Position, Vector3.new(Mouse.Hit.X, Pivot.Y, Mouse.Hit.Z))
CameraPos:PivotTo(Pivot:Lerp(CF, Time / math.deg(math.pi / .0006)))
char.CameraPos:PivotTo(Pivot:Lerp(CF, Time / math.deg(math.pi / .0006)))
Time += RunService.RenderStepped:Wait()
end
end)
RunService.Heartbeat:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CameraPos.CFrame
end)
local function onInputBegan(input, _gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
local Time = 0
while debounce == false do
if Time > math.deg(math.pi / 12) then break end
local Pivot = Character:GetPivot()
local CF = CFrame.lookAt(Pivot.Position, Vector3.new(Mouse.Hit.X, Pivot.Y, Mouse.Hit.Z))
Character:PivotTo(Pivot:Lerp(CF, Time / math.deg(math.pi / 10)))
Time += RunService.RenderStepped:Wait()
end
end
end
UserInputService.InputBegan:Connect(onInputBegan)
local function onInputEnded(input, _gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
debounce = true
wait()
debounce = false
end
end
UserInputService.InputEnded:Connect(onInputEnded)
local Head = Character:WaitForChild("Head")
--New R6 stuff
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Torso = Character:WaitForChild("Torso")
local Neck = Torso:WaitForChild("Neck")
local Waist = HumanoidRootPart:WaitForChild("RootJoint")
local RHip = Torso:WaitForChild("Right Hip")
local LHip = Torso:WaitForChild("Left Hip")
local LHipOriginC0 = LHip.C0
local RHipOriginC0 = RHip.C0
local NeckOriginC0 = Neck.C0
local WaistOriginC0 = Waist.C0
Neck.MaxVelocity = 1/9
RunService.RenderStepped:Connect(function()
local CameraCFrame = camera.CoordinateFrame
if Character:WaitForChild("Torso") and Character:WaitForChild("Head") then
local TorsoLookVector = Torso.CFrame.lookVector
local HeadPosition = Head.CFrame.p
if Waist then
if camera.CameraSubject:IsDescendantOf(Character) or camera.CameraSubject:IsDescendantOf(Player) then
local Point = Mouse.Hit.p
local Distance = (Head.CFrame.p - Point).magnitude
local Difference = Head.CFrame.Y - Point.Y
local goalNeckCFrame = CFrame.Angles(-(math.atan(Difference / Distance) * 0.5), (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0)
--Neck.C0 = Neck.C0:lerp(goalNeckCFrame*NeckOriginC0, 0.5 / 65).Rotation + NeckOriginC0.Position
local xAxisWaistRotation = -(math.atan(Difference / Distance) * 0.5)
local yAxisWaistRotation = (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 0.5
local rotationWaistCFrame = CFrame.Angles(xAxisWaistRotation, yAxisWaistRotation, 0)
local goalWaistCFrame = rotationWaistCFrame*WaistOriginC0
Waist.C0 = Waist.C0:lerp(goalWaistCFrame, .5 / .5).Rotation + WaistOriginC0.Position
local currentLegCounterCFrame = Waist.C0*WaistOriginC0:Inverse()
local legsCounterCFrame = currentLegCounterCFrame:Inverse()
RHip.C0 = legsCounterCFrame*RHipOriginC0
LHip.C0 = legsCounterCFrame*LHipOriginC0
end
end
end
end)
thats basically it. thanks for your time.