Im trying to make it so that the arm of the roblox player (r6) faces towards a player and then stretches out to them. Ive been trying for a while and cant seem to figure anything out. this is what I have so far.
local hb = game.ReplicatedStorage.MoveAssets.ggpistolhitbox:Clone()
hb.Parent = workspace
hb.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -19.85)
hb.Touched:Connect(function(part)
if part.Parent:FindFirstChildWhichIsA("Humanoid") then
if part.Parent ~= plr.Character then
plr.Character["Right Arm"].CollisionGroup = "Ghost"
local ArmMotor6D = plr.Character.Torso["Right Shoulder"]
local jointPosition = ArmMotor6D.Part0.CFrame:toWorldSpace(CFrame.new(0.9,0.25,0.25))
local cframe = CFrame.new(jointPosition.p, part.Parent.HumanoidRootPart.Position) * CFrame.Angles(math.pi/2, 0, 0) * CFrame.new(0, -1, 0)
ArmMotor6D.C0 = ArmMotor6D.Part0.CFrame:toObjectSpace(cframe)
local tween = ts:Create(plr.Character["Right Arm"],TweenInfo.new(1),{Size = Vector3.new(plr.Character["Right Arm"].Size.X,30,plr.Character["Right Arm"].Size.Z)})
tween:Play()
end
end
end)
What this does is spawn a hitbox, then if a humanoid is in the hitbox it stretches the arm towards the humanoidrootpart. currently it is facing the arm the wrong direction and it is rotating from the center of the arm instead of from the top of the arm.