How could i fix this error?

Hi so i have been having a problem with my script, So bassicly i want the foot of the custom character to face where the humanoid root is facing, But the problem is it just starts spining instead of facing the direction of the humanod root is facing

Sorry for the short video but do you see how his foot is spinning? how could i fix this?

1 Like

Well I dont think I can help much, but so others can help, consider posting your code as it would help others a lot!

Sorry i forgot to paste the code in really sorry

heres the main part thats not working

hum.Running:Connect(function()
	ProceduralModule:IkLegStep(left_IkTarget, left_RaycastPart, passenger.PrimaryPart, 0.5, 2, 1, 0.05, rayCastParams)
	left_IkTarget.Orientation = left_IkTarget.Orientation + Vector3.new(0, root.Parent.Torso.Orientation.Y, 0)

	task.wait(0.1)
	ProceduralModule:IkLegStep(right_IkTarget, Right_RaycastPart, passenger.PrimaryPart, 0.5, 2, 1, 0.05, rayCastParams)
	
	task.wait(0.1)
end)

heres the entire script:

local ProceduralModule = require(game:GetService("ReplicatedStorage").ProceduralModule2)

local runService = game:GetService("RunService")

local passenger = script.Parent
local root = passenger:FindFirstChild("HumanoidRootPart")
local hum = passenger:FindFirstChild("Humanoid")
local alignOrientation = root:FindFirstChild("AlignOrientation")

local target = workspace:FindFirstChild("Target")

--// IkTargets
local ikTargets = passenger:FindFirstChild("IkTargets")
local left_IkTarget = ikTargets:FindFirstChild("LeftTarget")
local right_IkTarget = ikTargets:FindFirstChild("RightTarget")

--// Raycast parts
local raycastParts = passenger:FindFirstChild("RaycastParts")
local left_RaycastPart = raycastParts:FindFirstChild("LeftRaycast")
local Right_RaycastPart = raycastParts:FindFirstChild("RightRaycast")


--// IKControls
local left_IKControl = hum:FindFirstChild("LeftLegIK")
local right_IKControl = hum:FindFirstChild("RightLegIK")

left_IKControl.Pole = root.LeftAtt
right_IKControl.Pole = root.RightAtt

--// RaycastParams
local rayCastParams = RaycastParams.new()
rayCastParams.FilterDescendantsInstances = {passenger}
rayCastParams.FilterType = Enum.RaycastFilterType.Exclude



runService.Heartbeat:Connect(function()
	local rayCast = workspace:Raycast(root.Position, -1000 * root.CFrame.UpVector, rayCastParams)

	if rayCast then
		local rotateToFloorCFrame = ProceduralModule:getRotationBetween(root.CFrame.UpVector, rayCast.Normal)
		local floorOrientedCFrame = rotateToFloorCFrame * CFrame.new(root.Position)

		local dz = (root.Position.Z - target.Position.Z)
		local dx = (root.Position.X - target.Position.X)
		local horizontalAngle = math.atan2(dx, dz)

		alignOrientation.CFrame = floorOrientedCFrame.Rotation * CFrame.fromOrientation(0, horizontalAngle, 0)
	end
end)

hum.Running:Connect(function()
	ProceduralModule:IkLegStep(left_IkTarget, left_RaycastPart, passenger.PrimaryPart, 0.5, 2, 1, 0.05, rayCastParams)
	left_IkTarget.Orientation = left_IkTarget.Orientation + Vector3.new(0, root.Parent.Torso.Orientation.Y, 0)

	task.wait(0.1)
	ProceduralModule:IkLegStep(right_IkTarget, Right_RaycastPart, passenger.PrimaryPart, 0.5, 2, 1, 0.05, rayCastParams)
	
	task.wait(0.1)
end)

In the main part that is not working, you can just put:

hum.Running:Connect(function()
	ProceduralModule:IkLegStep(left_IkTarget, left_RaycastPart, passenger.PrimaryPart, 0.5, 2, 1, 0.05, rayCastParams)
	left_IkTarget.Orientation = left_IkTarget.Orientation + Vector3.new(0, root.Parent.Torso.Orientation.Y, 0)
	task.wait(0.1)

	ProceduralModule:IkLegStep(right_IkTarget, Right_RaycastPart, passenger.PrimaryPart, 0.5, 2, 1, 0.05, rayCastParams)
	right_IkTarget.Orientation = right_IkTarget.Orientation + Vector3.new(0, root.Parent.Torso.Orientation.Y, 0)
	task.wait(0.1)
end)

or

hum.Running:Connect(function()
	ProceduralModule:IkLegStep(left_IkTarget, left_RaycastPart, passenger.PrimaryPart, 0.5, 2, 1, 0.05, rayCastParams)
	task.wait(0.1)

	ProceduralModule:IkLegStep(right_IkTarget, Right_RaycastPart, passenger.PrimaryPart, 0.5, 2, 1, 0.05, rayCastParams)
	task.wait(0.1)
end)

But Iā€™m not sure what will work though.

1 Like