Problem with player's R15

I want to change the orientation of the C0 of the players’s shoulders. I have a script that works with R6 but as soon as I tried using a modified version of it on a player’s R15, it didn’t worked at all.

I tried many things, the best solution I found was using a weld to replace the motor6D but I want to animate the shoulders.

I looked on other people posts and roblox documentation.

Does someone know how to fix my problem ? here the R6 script :


local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local char = plr.Character
game:GetService("RunService").RenderStepped:Connect(function()
    local c = workspace.CurrentCamera
    local direction = c.CFrame.LookVector
    
    local normalizedDirection = direction.Unit
    local verticalAngle = math.asin(normalizedDirection.y)
    
    char.Torso["Right Shoulder"].C0 = CFrame.new(1, 0.5, 0) * CFrame.Angles(verticalAngle, 1.55, 0)
    char.Torso["Left Shoulder"].C0 = CFrame.new(-1, 0.5, 0) * CFrame.Angles(verticalAngle, -1.55, 0)
    char.Torso["Neck"].C0 = CFrame.new(0, 1, 0) * CFrame.Angles(verticalAngle + 1.55, 3.15, 0)
end)


4 Likes

This could work:

local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local char = plr.Character
local humanoid = char:WaitForChild("Humanoid")

game:GetService("RunService").RenderStepped:Connect(function()
    local c = workspace.CurrentCamera
    local direction = c.CFrame.LookVector

    local normalizedDirection = direction.Unit
    local verticalAngle = math.asin(normalizedDirection.y)

    -- Adjust for R15 bone structure
    local rightArm = char:FindFirstChild("Right Arm")
    local leftArm = char:FindFirstChild("Left Arm")
    local neck = char:FindFirstChild("Neck")

    if rightArm and leftArm and neck then
        rightArm.C0 = CFrame.new(1, 0.5, 0) * CFrame.Angles(verticalAngle, 1.55, 0)
        leftArm.C0 = CFrame.new(-1, 0.5, 0) * CFrame.Angles(verticalAngle, -1.55, 0)
        neck.C0 = CFrame.new(0, 1, 0) * CFrame.Angles(verticalAngle + 1.55, 3.15, 0)
    end
end)

In this modified script:

  1. We use char:FindFirstChild("Right Arm"), char:FindFirstChild("Left Arm"), and char:FindFirstChild("Neck") to locate the appropriate bones in the R15 character, these bone names differ from the R6 structure
  2. We only apply the adjustments if we successfully find the corresponding bones, which should prevent errors in cases where the bones are not present

Good luck!

3 Likes

I’m pretty sure you used chatGPT. And this script won’t work because it’s not even the good names.

  1. I learned Lua from ChatGPT, I’m self taught.

^ ?

1 Like

Let me explain. R6 and R15 aren’t the same thing at all. They don’t work the same way. R6 store the motor6D of it in the torso. But R15 is in the body part concerned. Also with the R15, there’re RightUpperArm and LeftUpperArm which children are RightShoulder and LeftShoulder

1 Like

I see. So what do you want me to change @gunipotys?

1 Like

Also due to multiple bones for each arms and more. Just changing the RightShoulder and LeftShoulder C0 or C1 won’t work because of the complexity. But I can’t find how to fix it. I tried lots of things.

I think I found the solution ! Someone made a script on pastebin to make an arm follow the mouse, I’ll modify for my utilisation later. Here’s the link

If you want the script directly :

--- Services ---
local Players = game:GetService("Players");
local RunService = game:GetService("RunService");
wait();

--- Declarations ---
local Player = Players.LocalPlayer;
local Character = Player.Character or Player.CharacterAdded:Wait();

local Mouse = Player:GetMouse();

--- Character ---
local RightUpperArm = Character:WaitForChild("RightUpperArm");
local RightShoulder = RightUpperArm:WaitForChild("RightShoulder");
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart");

--- Execution ---
RunService.Stepped:Connect(function()
	local hit = Mouse.Hit;
	
	-- add the lookVector * 5000 to the hit.p to make the point more "dramatic" (remove it and you'll see why I did this)
	local direction = hit.p + (hit.lookVector * 5000);
	
	-- get the rotation offset (so the arm points correctly depending on your rotation)
	local rootCFrame = HumanoidRootPart.CFrame;
	local rotationOffset = (rootCFrame - rootCFrame.p):inverse();
	
	-- since CFrames are relative, put the rotationOffset first, and then multiple by the point CFrame, and then multiple by the CFrame.Angles so the arm points in the right direction
	RightShoulder.Transform = rotationOffset * CFrame.new(Vector3.new(0, 0, 0), direction) * CFrame.Angles(math.pi / 2, 0, 0);
end)

For example, by modifying a little bit the script. I believe I made a script that make the arm follow the Y axis of the mouse.Hit and still play the animations related to this motor6D :

--- Services ---


local Players = game:GetService("Players");
local RunService = game:GetService("RunService");
wait();

--- Declarations ---
local Player = Players.LocalPlayer;
local Character = Player.Character or Player.CharacterAdded:Wait();

local Mouse = Player:GetMouse();

--- Character ---
local RightUpperArm = Character:WaitForChild("RightUpperArm")
local RightShoulder = RightUpperArm:WaitForChild("RightShoulder")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")



--- Execution ---
RunService.Stepped:Connect(function()

	-- add the lookVector * 5000 to the hit.p to make the point more "dramatic" (remove it and you'll see why I did this)
	local direction = CFrame.lookAt(RightUpperArm.Position, Mouse.Hit.Position).LookVector.Y
	local Add = CFrame.Angles(math.asin(direction), 0, 0)

	-- since CFrames are relative, put the rotationOffset first, and then multiple by the point CFrame, and then multiple by the CFrame.Angles so the arm points in the right direction

	RightShoulder.Transform = RightShoulder.Transform * Add
end)
```l
2 Likes

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