Rig Rotating the wrong positions

Hello.
Im currently making a AI where the characters “Waist” Motor6D will rotate to the targetpart positions. The code is very simple.

wait()
local waist = script.Parent.UpperTorso:WaitForChild("Waist")
local origin = waist.C0
while game["Run Service"].Heartbeat:Wait() do
	waist.C0 = CFrame.new(waist.C0.Position,waist.C0.Position+(game.Workspace.Target.Position - waist.C0.Position).Unit)
end

the idea is that the script would make the waist c0 turn to a rotation by setting the default waistc0 positions and then target the rotation on the direction of the targetparts.

However the results were like this
image
It just rotates on a weird rotation that has nothing to do with its direction. I seem to be stucking on this for a while now. I tried to find solutions but It doesnt seem to work.

Please help!

1 Like

if you need to kill players then try this:

function findNearestTorso(pos)
	local list = game.Workspace:children()
	local torso = nil
	local dist = math.huge
	local temp = nil
	local human = nil
	local temp2 = nil
	for x = 1, #list do
		temp2 = list[x]
		if (temp2.className == "Model") and (temp2 ~= script.Parent) then
			temp = temp2:findFirstChild("HumanoidRootPart")
			human = temp2:findFirstChild("Humanoid")
			if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
				if (temp.Position - pos).magnitude < dist then
					torso = temp
					dist = (temp.Position - pos).magnitude
				end
			end
		end
	end
	return torso
end
while true do
	wait(0)
	local target = findNearestTorso(script.Parent.HumanoidRootPart.Position)
	if target ~= nil then
		script.Parent.CFrame = CFrame.new(script.Parent.Position, target.Position)
	end
end

hope its helps!

1 Like

try this instead

wait()
local waist = script.Parent.UpperTorso:WaitForChild("Waist")
local origin = waist.C0
while game["Run Service"].Heartbeat:Wait() do
	waist.C0 = CFrame.new(waist.C0.Position, game.Workspace.Target.Position-script.Parent.UpperTorso.Position-waist.C0.Position)
end

59c258b63c0f91d66a3ece6be21f1ea1

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