IKControl Arm Bug

Hi everyone, today I wanted to make a door with IK animation of the player. This is the 2nd question on the dev forum today :joy:. Everything more or less works, but something weird is happening with the arms…It makes the animation look terrible. Help, please.

I need not bugged, smooth arm animation. (like door animation in emergency hamburg)

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.Enabled = true
		ikControl.Target = workspace.Door.Base.Attachment

		-- Wait for 1 second
		wait(1)

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

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

There are two same scripts in 2 parts. It is server script.
Please tell me how to fix it or give me working script.

The only way you can do this without them looking too buggy is to set the ChainRoot to the UpperTorso and the EndEffector to the left upper or lower arm. Perhaps decrease the weight of the IKControl as well, maybe to 0.9 or lower and see what comes out of it

1 Like

Ok, I will try it now, thank you!

It’s worse than it was :rofl::rofl::rofl:

MY AVATAR IS DANCING NOW

Oh you’re using IKControlType to position, didn’t notice that. In this case using the UpperTorso definitely won’t do it as you’d be trying to force its position to the door.
Perhaps try using LookAt instead of Position?

Ok, I will try it now, thanks!


His hand went numb

1 varient: with

ikControl.EndEffector = character:FindFirstChild(LeftHand, true)
ikControl.ChainRoot = character:FindFirstChild(LeftUpperArm, true)

2 varient: with

ikControl.EndEffector = character:FindFirstChild(LeftHand, true)
ikControl.ChainRoot = character:FindFirstChild(UpperTorso, true)
ikControl.Weight = 0.7

Yeahh I don’t know man, I haven’t worked with IKControls enough to understand this. Sorry, good luck with your issue

1 Like

Okey! Thanks for trying to help.

The problem seems to be from the touch event firing while the IKControl is still enabled.

Try replacing a part of your code with this:

if humanoid and not humanoid:GetAttribute("IKInProgrss") then
	humanoid:SetAttribute("IKInProgrss", true)
	-- 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.Enabled = true
	ikControl.Target = workspace.Door.Base.Attachment

	-- Wait for 1 second
	wait(1)

	-- Clear the IKControl target
	ikControl.Enabled = false
	ikControl.Target = nil
	humanoid:SetAttribute("IKInProgrss", false)
end
1 Like

You could try making it so the IK also only works when you’re facing the door, via.

if Part.CFrame:toObjectSpace(Character.PrimaryPart.CFrame).Z < 0 then
print("Infront of me")
end
-- or
if Character.PrimaryPart.CFrame:toObjectSpace(Part.CFrame).Z < 0 then
print("Infront of me")
end

The second problem is that one stated above by @Mastercheterpoop basically how touch events work is they’ll keep firing over and over again if you dont have a debounce or something stopping it. This will start stack up and will spam it off and on over and over again.

-- Wait for 1 second
	wait(1)

	-- Clear the IKControl target
	ikControl.Enabled = false
	ikControl.Target = nil

Instead of using a attribute you can just check if the ikControl is enabled or not

if humanoid then
if humanoid:FindFirstChild("IKControl") and  humanoid:FindFirstChild("IKControl").Enabled == true then return end
end
1 Like

Thank you very much! It works!

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