Arms flying away for some reason

Hello. I have made this script where the driver’s arm holds the steering wheel.

local rs = game:GetService("RunService")
local wheel = script.Parent.Parent.Parent.Body.Wheel

script.Parent.Parent:GetPropertyChangedSignal("Occupant"):Connect(function()
	if script.Parent.Parent.Occupant then
		local occupant = script.Parent.Parent.Occupant.Parent
		
		local torso = occupant:FindFirstChild("Torso")
		local larm = occupant:FindFirstChild("Left Arm")
		local rarm = occupant:FindFirstChild("Right Arm")
		
		local lmotor = torso:FindFirstChild("Left Shoulder")
		local rmotor = torso:FindFirstChild("Right Shoulder")
		
		local lwheelgrip = wheel.Wheel.LAttachment
		local rwheelgrip = wheel.Wheel.RAttachment
		
		rs.Heartbeat:Connect(function()
			local p0 = lmotor.Part0
			local ljointposition = (p0.CFrame * lmotor.C0).Position
			local rjointposition = (p0.CFrame * rmotor.C0).Position
			
			local llook = CFrame.lookAt(ljointposition, lwheelgrip.WorldPosition)
			local rlook = CFrame.lookAt(rjointposition, rwheelgrip.WorldPosition)
			
			local ar = CFrame.new()
			
			local ldesiredposition = llook * ar
			local rdesiredposition = rlook * ar
			
			local newlc0 = p0.CFrame:ToObjectSpace(ldesiredposition) * lmotor.C1
			local newrc0 = p0.CFrame:ToObjectSpace(rdesiredposition) * rmotor.C1
			
			lmotor.C0 = newlc0
			rmotor.C0 = newrc0
		end)
	end
end)

However, when I tested it, my arms flew away.


Is there a fix to this?

fixed it by setting initial c0/c1 values

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