How to pivot character's arms?

Hi Devforum! I programmed a fully-functioning system that catches balls and that makes your arms follow the ball that’s currently in the air. But the problem is that it doesn’t look correctly when the arm stays in its same position while it follows the ball, so I want to pivot the arms to their selected positions, so I need your help!

What do you want to achieve?

  • Both arms pivoting to their own selected positions.

What is the issue?

  • Both arms stays in its positions, and doesn’t pivot around the given position.

Differences below:

the game Football Fusion’s example:
image

My arms’s positioning:
image

As you can see there is a difference, Football Fusion pivots their arms to the red points that I have just shown at the screenshot, and my arms stay at their same position.

Here’s my code’s snippet:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local character = player.Character or player.CharacterAdded:Wait()
local humanoidrootpart = character:WaitForChild("HumanoidRootPart")
local Torso = character:WaitForChild("Torso", true)
local LeftArm = character:WaitForChild("Left Arm", true)
local RightArm = character:WaitForChild("Right Arm", true)
local Humanoid = character:WaitForChild("Humanoid")

local LSh = character:WaitForChild("Torso")["Left Shoulder"]
local RSh = character:WaitForChild("Torso")["Right Shoulder"]
local CFN, CFA, asin, tan = CFrame.new, CFrame.Angles, math.asin, math.tan

local Settings = require(game.ReplicatedStorage.Modules:FindFirstChild("SettingsModule"))
local BallsStorage = Settings.BallStorage

local RunService = game:GetService("RunService")

local CatchDuration = 3
local CatchDebounce = false
local ClosestBall = nil
local WeldL = nil
local WeldR = nil

local LeftOffset = LSh.C0
local RightOffset = RSh.C0

local function ApplyWelds(ParentTarget)
local LsWeld = Instance.new("Weld", Torso)
LsWeld.Name = "LSweld"	
LsWeld.Enabled = true	
LsWeld.Part0 = Torso	
LsWeld.Part1 = LeftArm	
LsWeld.C0 = Torso:FindFirstChild("LeftCollarAttachment").CFrame
	
local RSweld = Instance.new("Weld", Torso)
RSweld.Name = "RSweld"	
RSweld.Enabled = true	
RSweld.Part0 = Torso	
RSweld.Part1 = RightArm	
RSweld.C0 = Torso:FindFirstChild("RightCollarAttachment").CFrame
	
WeldL = LsWeld		
WeldR = RSweld		
LSh.Enabled = false	
RSh.Enabled = false		
end

local function RemoveWelds()
if WeldL and WeldR then	
WeldL:Destroy()
WeldR:Destroy()		
end		
		
WeldL = nil	
WeldR = nil	
LSh.Enabled = true	
RSh.Enabled = true		
end

local function FollowBall()
	print("Following ball called.")

	if ClosestBall and CatchDebounce then else return end
	if LSh and RSh then else return end
	if Humanoid.Health <= 0 then return end

	local LeftPivot  = Torso.CFrame * WeldL.C0
	local RightPivot = Torso.CFrame * WeldR.C0

	local LeftTHING  = CFN(LeftPivot.Position,  ClosestBall.Position) * CFA(math.pi/2,-math.pi/2, 0)
	local RightTHING = CFN(RightPivot.Position, ClosestBall.Position) * CFA(math.pi/2, math.pi/2, 0)

	WeldL.C0 = Torso.CFrame:toObjectSpace(LeftTHING)
	WeldR.C0 = Torso.CFrame:toObjectSpace(RightTHING)

	print("both arms are following the ball.")
end	

Any help is appreciated!

I really do need help with it, I can’t figure it out. And ignore the pants, it got content deleted.

1 Like

Could you edit the pivot of the arms?

I don’t know how to pivot it, but i can change it’s position.

Hey, If you still have not found the answer, you have to set the weld’s C1 value aswell. C1 value is the offset from the center of part1. since you dont have this value set, part1’s c1 is 0,0,0 meaning when welded, the part1 will be welded to the cframe of c0 by its center. Hope this helps. also, can you tell me the logic behind the code you use to actually make the arms point towards the ball?

1 Like

I actually found the same exact solution that you’ve just explained, altough it was months ago. But i appreciate you bumping this thread just incase i was stuck still.

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