What I am trying to learn is…
I’d like to know in which order the Task Scheduler tasks are performed because I can’t seem to understand at which point in the task tree events like Changed or AncestryChanged are fired at when object properties are changed?
My issue is that…
I’m getting different results every time I run my benchmarks of trying to trace this tree as shown in the documentation. I am trying to trace when the Player joins, when the Character is added and when the Character parent is changed. Here is the Task Scheduler Priority:
I really don’t understand why the client comes first in the list not that I even care about this in the first place for my use case, but why? When you join a server, don’t you first have to wait for the server to complete “Replication Send Jobs” task as seen in the bottom?
When do events fire server side? Do they (they, referring to Changed and AncestryChanged) run immediately when you change a property?
What have I tried to do?
I have tried to understand the following threads without understanding the order:
But I simply can’t understand why my output gives different results every time:
After this, I tried printing this along side the Heartbeat step: game.Players:FindFirstChild("[redacted]").Character.Parent
(Obviously going to fail if nil, but I wanted this on purpose).
Please take note here that the Player itself did not get instantiated at all and SOMEHOW the Character parent was already set to Workspace… then next Stepped it was nil!?
What is happening here?
And sometimes it takes ages to load… but why does the player in the first picture load in before the Stepped… but in the other pictures it does not and sometimes it even loads in after the Heartbeat.
And again… the question remains… where in which part of the Task Scheduler Priority tree do those events fire? (The “7 7” that you see in the print are the number of times Stepped and Heartbeat have ran already).
Here is my script for those who want to try this out themselves (ignore the LoadCharacter and character auto loads, I tried without them and it seems to not affect speed):
local Players = game:GetService("Players")
local step = 0
local heartStep = 0
game:GetService('RunService').Stepped:Connect(function()
print("Stepped")
step += 1
end)
game:GetService('RunService').Heartbeat:Connect(function()
print("Heartbeat")
heartStep += 1
end)
Players.CharacterAutoLoads = false
Players.PlayerAdded:Connect(function(player)
print("Player added")
player.CharacterAdded:Connect(function(character)
print("Character object instantiated")
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
humanoid.Parent:BreakJoints()
end)
humanoid.Parent.AncestryChanged:Connect(function(_, parent)
if parent == game.Workspace then
print("Parent is now workspace", step, heartStep)
humanoid:ChangeState(Enum.HumanoidStateType.Dead)
end
end)
end)
player:LoadCharacter()
end)