IK hand
MatsProg
lua
2 years ago
932 B
3
Indexable
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local rightArm = character:WaitForChild("Right Arm") local rightHand = character:WaitForChild("RightHand") local target = workspace.Target -- the part or position you want the arm to reach local lengthUpperArm = rightArm.UpperArmLength local lengthForearm = rightArm.ForearmLength while true do local distance = (target.Position - rightHand.Position).Magnitude if distance > lengthUpperArm + lengthForearm then local targetPosition = target.Position - rightArm.CFrame:VectorToWorldSpace(Vector3.new(0, lengthUpperArm, 0)) humanoid:MoveTo(targetPosition) else local targetRotation = CFrame.lookAt(rightHand.Position, target.Position) rightArm.CFrame = targetRotation * CFrame.new(0, -lengthUpperArm, 0) end wait() end
Editor is loading...