I’m not the best scripter in the world. What are some ways that I can figure which one takes the least amount of performance?
Or can someone with experience just tell me straight up which method uses up less performance and I can go about my day?
Depends, the only difference is that :TakeDamage()
respects force fields. So if the player has a force field on them, they won’t be damaged.
I’m sorry. I didn’t ask for that, you clearly read my post wrong.
Which one uses the least performance?
Back to what you said… I know that it checks for the forcefields already. Sorry I came pretty blunt with what you said. Maybe as I think about it more, a built in function that requires checks for a forcefield would be more detrimental to performance…
So… in conclusion, don’t use :TakeDamage if you’re trying to save performance.
You’re missing my point. TakeDamage is literally just:
if humanoid.Parent:FindFirstChildOfType("ForceField") == nil then
humanoid.Health -= damage
end
You will see maybe 1-2ms of difference, but it won’t actually affect performance negatively at all.
There aren’t any significant performance differences between either of them. I prefer to use :TakeDamage() mostly because it merely feels easier and trusty.
My friend used tick…
it’s 250% better to use Humanoid.Health = Humanoid.Health - damage
rather than :TakeDamage()
I got these results:
Over 20,000 tests, less than a millisecond (500 microseconds about) difference in average. It’s won’t be noticeable at all.
Edit: There’s something wrong with my math, give me a sec.
With the actual results (I forgot to divide lol):
These were averaged out over 1 million tests for each -=
and TakeDamage
. The difference is 102.26893424987994763
nano seconds, which is quite literally no difference from our standpoint, but yes -=
is technically faster than TakeDamage
if you want to ignore forcefields.
In all honestly, it clearly doesn’t matter which is used and I’m not too sure why you’re asking this question. The difference between the 2 are so slightly insignificant it won’t change how it performs even if used thousands of times.
I don’t know, I’d guess it would be :TakeDamage() but i’m not sure, I think that probably methods perform about the same, if one is faster than the other, then it’s faster by a half of a half of a a half of a half of a half of a second.
I already pointed out the solution.
I already pointed out the solution [2].