i don’t understand this, if i click play with the IK target nil, no error, but if i change the value to nil by a script, error shows
script.Parent.Touched:Connect(function(b)
local Player = game.Players:FindFirstChild(b.Parent.Name)
if Player then
local IKControl = Player.Character.HumanoidRootPart.IKControl_leftarm
local door = script.Parent.Parent.handIK
IKControl.Target = door
wait(2)
IKControl.Target = nil -- **here i want to make the value nil but without giving the error, it needs to stay nil because when the player gets away from door, the arm needs to come back to normal.**
end
end)
the error that shows in the output is this one: Missing IkControl Target (x613) - Studio
Ok, so instead of trying to make the Target nil, forget the target and play around with the Weight propriety, I can’t explain it really good, so just check the code, it’s a nice solution.
script.Parent.Touched:Connect(function(b)
local Player = game.Players:FindFirstChild(b.Parent.Name)
if Player then
local IKControl = Player.Character.HumanoidRootPart.IKControl_leftarm
local door = script.Parent.Parent.handIK
local hand_collision = Player.Character.HandCollision_l
local ts = game:GetService("TweenService")
local tween = ts:Create(IKControl, TweenInfo.new(1), {Weight = 1})
local tween1 = ts:Create(IKControl, TweenInfo.new(0.5), {Weight = 0})
tween:Play()
hand_collision.CanCollide = true
IKControl.Target = door
task.wait(0.7)
tween1:Play()
hand_collision.CanCollide = false
end
end)