If I use task.desynchronize in a script that is not contained under and actor, what exactly will it do?
I mean I'm just sort of confused by how it works and whatnot
Mainly anything to do with parallel luau just blows up my head
Reason I'm wondering though is because I'm working on a server sided NPC system, and parallel lua article mentions that it is handy for systems including NPCs
#Understanding task.desynchronize in NPC usecase.
1 messages · Page 1 of 1 (latest)
For example, would this be one usecase
function FindNearestTarget()
task.desynchronize()
-- Code to get nearest Target
return Target
end
function GoToTarget()
Target = FindNearestTarget()
task.synchronize()
Humanoid:MoveTo(Target.Position)
end
The reason being because we can't modify any states in a desynchronized script as the Roblox API states.
I am also interested. I'm pr sure its specifically for actors but maybe I'm wrong
Yeah, I hope it just defers it to like a random "actor", but I dont know
If you call desyncronize without a actor Roblox will give you a error I believe
Actors and models are the same so you can replace your NPC model with a actor
It hasn't errored for me
Warning?
Nothing
I need to check again
but last I tried
I'm pretty sure no errors or warnings happened
I remember it giving a error or something for me but it was a long time since I tested
It might just ignore the command
I hope not
Check the micro profiler to make sure it worked
Or one way you find out try changing the name of the NPC while desynchronized
If it lets you change the name then it's still synchronized
I'll try it out
@opaque scarab upon testing this, I didn't get any errors on trying to change the name
all it did was do... nothing?
The name didn't change
but also
the scripts execution stopped
after the task.desynchronize
maybe an error?
Wait hold on
Yeah it's weird
It seems the code execution just stops?
Like as if there is an invisible error
i would say report it to roblox but roblox be annoying
yea
if you change the npc model to a actor it should start working
be warned if you turn the npc to a actor each npc will require a new module npcs will no longer share the same module
if your npcs use lots of modules this could increase ram usage
BTW, small update to this, calling task.synchronize on a script without an actor will give you a warning now. Likewise for task.desynchronize
that doesnt seem to be the case. i just tested this and im not able to damage NPC with guns. thoughts?
yeah they have the same properties but i dont think they behave the same since i put all of npcs instances inside an actor and i wasnt able to damage it unlike with a regular model