IKControl error

Hi everyone, today I wanted to make a door with player’s IK animation. Everything more or less works, but in the output, I get the warning “Missing IKControl Target (x5000)” a bunch of times per second. Because of this the game starts to lag. Please help.

local part = script.Parent

-- Function to be called when a player touches the part
local function onTouch(hit)
	local character = hit.Parent
	local humanoid = character:FindFirstChildOfClass("Humanoid")

	-- Check if the humanoid exists
	if humanoid then
		-- Create IKControl if it doesn't exist
		local ikControl = humanoid:FindFirstChild("IKControl")
		if not ikControl then
			ikControl = Instance.new("IKControl")
			ikControl.Parent = humanoid
			ikControl.Type = Enum.IKControlType.Position
			ikControl.EndEffector = character:FindFirstChild("LeftHand", true)
			ikControl.ChainRoot = character:FindFirstChild("LeftUpperArm", true)
		end

		-- Set the IKControl target
		ikControl.Target = workspace.Door.Base.Attachment

		-- Wait for 1 second
		wait(1)

		-- Clear the IKControl target
		ikControl.Target = nil
	end
end

-- Connect the onTouch function to the Touched event of the part
part.Touched:Connect(onTouch)

Please tell me how to fix it or what I should use instead of nil.

This would cause the issue

1 Like

@SomeFedoraGuy Is correct in that ikControl.Target = nil is causing the warnings to appear, but I would like to add that in order to fix your problem you’ll need to do ikControl.Enabled = false before you set the target to nil. Do note that by doing so you’ll need to use ikControl.Enabled = true whenever you’d like to reactivate the ikControl

1 Like

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