Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

can somebody help make this script work with R6 character models?

Asked by 2 years ago

I need this to work for R6 because when im in R15 it makes the tool bounce up and down, and just look weird. Is there a way I can make this work using R6? Thanks.

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 Neck = Head:WaitForChild("Neck")

local Arm = Character:WaitForChild("RightUpperArm")

local Shoulder = Arm:WaitForChild("RightShoulder")

local Humanoid = Character:WaitForChild("Humanoid")

local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local NeckOriginC0 = Neck.C0

local ShoulderOriginC0 = Shoulder.C0

Neck.MaxVelocity = 1/3

RunService.RenderStepped:Connect(function()

local CameraCFrame = Camera.CoordinateFrame



if Character:FindFirstChild("UpperTorso") and Character:FindFirstChild("Head") then

    local ArmLookVector = Arm.CFrame.lookVector

    local HeadPosition = Head.CFrame.p



    if Neck and Shoulder then

        if Camera.CameraSubject:IsDescendantOf(Character) or Camera.CameraSubject:IsDescendantOf(Player) then

            local Point = PlayerMouse.Hit.p



            local Distance = (Head.CFrame.p - Point).magnitude

            local Difference = Head.CFrame.Y - Point.Y



            Neck.C0 = Neck.C0:lerp(NeckOriginC0 * CFrame.Angles(-(math.asin(Difference / Distance) ), (((HeadPosition - Point).Unit):Cross(ArmLookVector)).Y, 0), .5 / 2)

            Shoulder.C0 = Shoulder.C0:lerp(ShoulderOriginC0 * CFrame.Angles(-(math.asin(Difference / Distance)), (((HeadPosition - Point).Unit):Cross(ArmLookVector)).Y, 0), .5 / 2)

        end

    end

end 

end)

0
I'm not sure how to put the code into a format, it automatically did that. Sorry. Huntsman70 0 — 2y

Answer this question