Arm Stretching System

Hello, I currently have problems with my arm stretching system.

Pain.rbxm (26,0 KB)

This gif below shows what I want to achieve, and what I have achieved.

Why is the red guy having a seizure?

In all seriousness, try messing around with an “IKControl” Instance in the limbs of the character.

How would I make the R6 character perfectly look towards the things with IKControl?
I only acheive this with R6.

End part should be the part, and select lookat

Doesn’t seem to work.

Feels like it made it worse
image

Priority should be 1

Doesn’t change anything.

local function Point_C0_To_Mouse(Motor6D, WorldCFrame, Stored_C1, Stored_C0)
	local Stored_C0 = Motor6D.C0
	local Part1_CFrame = Motor6D.Part1.CFrame
	local RelativeTo_Part1 = Stored_C0 * Stored_C1:Inverse() * Part1_CFrame:Inverse() * WorldCFrame * Stored_C1
	RelativeTo_Part1 -= RelativeTo_Part1.Position

	local Goal_C0 = RelativeTo_Part1 + Stored_C0.Position
	return Goal_C0
end


local RightShoulder = torso["Right Shoulder"]
local LeftShoulder = torso["Left Shoulder"]
--local Mouse = game.Players.LocalPlayer:GetMouse()
local RightArm = script.Parent:WaitForChild("Right Arm")
local LeftArm = script.Parent:WaitForChild("Left Arm")


-- Left
local Stored_C1_Left = LeftShoulder.C1
local Stored_C0_Left = LeftShoulder.C0

-- Right
local Stored_C1_Right = RightShoulder.C1
local Stored_C0_Right = RightShoulder.C0


RunService.Stepped:Connect(function()
	-- Right
	local Mouse_Pos = (workspace.Model.Right.CFrame *workspace.Model.Right.Blue.CFrame).Position
	RightShoulder.C0 = Point_C0_To_Mouse(RightShoulder, CFrame.lookAt((torso.CFrame*Stored_C0_Right).Position , Mouse_Pos),Stored_C1_Right, Stored_C0_Right) * CFrame.Angles(0,0, math.deg(-90))
	--RightArm.Size = Vector3.new(1,((torso.CFrame*RightShoulder.C0).Position-Mouse_Pos).Magnitude,1)
	
	-- Left
	local Mouse_Pos = workspace.Model.Left.Blue.WorldPosition
	LeftShoulder.C0 = Point_C0_To_Mouse(LeftShoulder, CFrame.lookAt((torso.CFrame*Stored_C0_Left).Position, Mouse_Pos),Stored_C1_Left, Stored_C0_Left) * CFrame.Angles(0,0, math.deg(90))
	local Distance = ((torso.CFrame*Stored_C0_Left).Position-Mouse_Pos).Magnitude
	LeftArm.Size = Vector3.new(1,Distance,1)
	LeftShoulder.C1 = Stored_C1_Left + Vector3.new(0,Distance/2-.5,0)
	--LeftShoulder.C1 = Stored_C1_Left* CFrame.new(0,Distance-.5,0)
end)

This is the current script, I just need C0 to work properly at this point, since it’s not facing towards the object, it’s sometimes facing 5000 metres in the sky for some reason.

I found the solution my own,

RunService.Stepped:Connect(function()
	-- Right
	local Mouse_Pos = (workspace.Model.Right.CFrame *workspace.Model.Right.Blue.CFrame).Position
	RightShoulder.C0 = Point_C0_To_Mouse(RightShoulder, CFrame.lookAt((torso.CFrame*Stored_C0_Right).Position , Mouse_Pos),Stored_C1_Right, Stored_C0_Right) * CFrame.Angles(0,0, math.rad(90))
	local Distance = ((torso.CFrame*Stored_C0_Right).Position-Mouse_Pos).Magnitude
	RightArm.Size = Vector3.new(1,math.clamp(Distance,1,5),1)
	RightShoulder.C1 = Stored_C1_Right + Vector3.new(0,math.clamp(Distance/2-.5,0,2.4),0)
	
	-- Left
	local Mouse_Pos = (workspace.Model.Left.CFrame *workspace.Model.Left.Blue.CFrame).Position
	LeftShoulder.C0 = Point_C0_To_Mouse(LeftShoulder, CFrame.lookAt((torso.CFrame*Stored_C0_Left).Position, Mouse_Pos),Stored_C1_Left, Stored_C0_Left) * CFrame.Angles(0,0, math.rad(-90))
	local Distance = ((torso.CFrame*Stored_C0_Left).Position-Mouse_Pos).Magnitude
	LeftArm.Size = Vector3.new(1,math.clamp(Distance,1,5),1)
	LeftShoulder.C1 = Stored_C1_Left + Vector3.new(0,math.clamp(Distance/2-.5,0,2.4),0)
	--LeftShoulder.C1 = Stored_C1_Left* CFrame.new(0,Distance-.5,0)
end)

It was at this part.
Using math.rad instead of math.deg

2 Likes

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