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?
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.
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.)
local humanoid = character.Humanoid
local server_stats = character.Stats
local client_stats = game.Players:GetPlayerFromCharacter(character).Stats
local target = server_stats.Target
local walking = server_stats.Walking
local attacking = server_stats.Attacking
local weaponId = client_stats.Weapon
if target.Value then
walking.Value = false
--Rotating character towards dummy and vice versa
--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)
Are you trying to check for MoveToFinished after calling the MoveTo() function? (or WalkToPoint)
I am calling the MoveTo() function, specifically the Humanoid MoveTo Without Time out which is in the wiki.
Why not pass your function into the “andThen()” somehow?
Will look into that, thanks.
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!