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.