So recently, I’ve been tasked with going through an old place my friend got from his friend and fixing the scripts - I noticed an API with the deprecated LoadLibrary() which was related to the leaderboard stats. After converting (most) of it to a more “new” version, I found a script that registers whether a player has died.
Player.CharacterAdded:connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:wait()
leaderstats.Deaths.Value = leaderstats.Deaths.Value + 1
--Check if killed by player etc
end)
Which drew my attention to line 3:
Humanoid.Died:wait()
After looking into it a bit, it seems people use :wait() alongside an event - i.e. event:wait()
What does :wait() do? If it was just a matter of waiting before the event ran or afterwards, why can’t you just do wait() the line before/after? Surely there’s a difference between :wait() and wait()?
Tl;dr Difference between “wait()” and “event:wait()”
wait() will simply pause the script for a very short period, but event:Wait() will pause the script until the event fires. You can learn more here: Events | Documentation - Roblox Creator Hub
FYI the :Wait() method of events should have an uppercase “W”. The lowercase one is deprecated. Technically still works, but best to stick with what is supported. The normal wait() function is still lowercase.
It still works, but it’s deprecated. When something is deprecated, it’s not removed (because that could break a lot of stuff), but it will no longer be supported. Thus, if it does break (or they make a change to the capitalized Wait version), then it will probably not be fixed.