Notifications
Clear all

[Closed] Runtime error: Key index out of range

Hi,

I got the following:

	function updatePathCon = (
		local arrKeys = $box.position.controller.keys
		local fPercent = calcKeys()
		deleteKey $box.pos.controller 1
		with animate on (
			at time 1s $box.position.controller.percent = fPercent
		)
	)

And it throws the error

>> MAXScript Rollout Handler Exception: -- Runtime error: Key index out of range in deleteKey: 1 <<

What do I do now? ^^

2 Replies

Got it: Since I’m animating the PERCENT Property I also need to access the keys of this property and not of the controller itself!

it normally means you are trying to access a number(Index) that does not exist.

I normally see this error when using a for loop like the one bellow:

array= #(“name01”,“name02”)
for i=1 to 100 do
(
print array[i].name
)

as the array only has 2 objects in it it will try to access a non-existent index once it goes past two.