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:
My arms’s positioning:
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!