MoveToFinished() not triggering occasionally

I have been working on a project which only a few days ago, the MoveToFinished() function started giving me trouble occasionally, where at times it does not trigger anything.

I yield my MoveToFinished() event once on CharacterAdded and I do not disconnect it at any time. I do this through a module script.

I do not know what is the cause of this issue and I couldn’t reproduce it on a different place than the project I am working on so I am still a bit uncertain what the issue may be. However, I reverted my place to a version where to my memory, I never had any issues with the MoveToFinished and now I am getting issues in it.

What should I be checking to figure out the cause of this issue?

3 Likes

Is there a script that you are using to detect the MoveToFinished?

I try to print something immediately after the MoveToFinished event and the rest of the code. Yet, nothing prints occasionally and so does the rest of the code.

1 Like

Can you show the code used to do this?

Here is the code which I yield on CharacterAdded, it incorporates with it a lot of ModuleScripts however that is irrelevant as it does work occasionally yet at times simply nothing fires. (Can confirm this because it works at times whilst occasionally it does not print the very first line after the MoveToFinished event, hence it wasn’t triggered at all.)

function module.fire(character)
	--Basic variables
	local humanoid = character.Humanoid
	humanoid.MoveToFinished:Connect(function()
		print("Triggered MoveToFinished")
		--Containers
		local server_stats = character.Stats
		local client_stats = game.Players:GetPlayerFromCharacter(character).Stats
		--Variables
		local target = server_stats.Target
		local walking = server_stats.Walking
		local attacking = server_stats.Attacking
		local weaponId = client_stats.Weapon
		--Process
		if target.Value then
			walking.Value = false
			--Rotating character towards dummy and vice versa
			general.humanoid.rotate(character, target.Value)
			--Triggering the first attack
			attacking.Value = true
			--Picking and playing animation
			local pickedWeapon = dictionaries.weapons.GetInfo(weaponId.Value)
			local animations = pickedWeapon.Animations
			local pickedAnimation = tonumber(general.picker.pick(animations))
			local animationId = dictionaries.animations.GetInfo(pickedAnimation).animationId
			general.animation.play(character, animationId, "Attack", 2)
		end
	end)
end
2 Likes

Are you trying to check for MoveToFinished after calling the MoveTo() function? (or WalkToPoint)

1 Like

I am calling the MoveTo() function, specifically the Humanoid MoveTo Without Time out which is in the wiki.
https://developer.roblox.com/api-reference/event/Humanoid/MoveToFinished

2 Likes

Why not pass your function into the “andThen()” somehow?

2 Likes

Will look into that, thanks.

1 Like

I have tested it with a normal MoveTo() event and it is not giving me trouble. However, I have no doubt that if I play around with it I could get it to work with the MoveTo Without Time out version as it haven’t worked yet on my first attempt. Thanks!

1 Like