![]() ![]() The “performance gain” from direct indexation over using a function is negligible. No more than a few unnoticeable milliseconds. Objectively speaking though GetPlayerFromCharacter is slower than the second option because it’s internally a loop versus indexing a table member but in terms of practicality the second one is impractical, though when I say slow I don’t mean dramatically, just marginally. Performance is a negligible concern and you don’t need to worry about it. You have a model and you’re checking to see if any of the players hold a reference to that model via the Character property, thus making that CharacterModel = Player.Character (they’re the same model). The second one is safer because it compares references. the player’s name is Name), the property will be indexed due to its precedence, causing an error when trying to further interact with that variable in assumption that it indexed a player. In the instance that a player’s name is that of a property (e.g. The second example is prone to unexpected behaviour or errors because a player can share a name with a property or a child object and those might be indexed instead of the real player. The second one attempts to index a string on the Players service. GetPlayerFromCharacter goes through all Players in the game and compares if their Character property (a reference to the Player’s character model) is equivalent to the model you pass in the function. They look the same but they’re fundamentally different. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |