Parameter question

Let’s say I have a function to create a hitbox. One of the parameters is for knockback direction.

function createHitbox(otherParametersBlahBlahBlah, knockbackDirection)
--create hitbox
end

I then create a hitbox, and create a touched event for it. Then, I put the knockbackDirection as the, well, knockback direction, when it comes time to apply it.
Now, I’ll call it to create a hitbox for an object, applying it in the opposite direction the object is facing:

createHitbox(parametersAndStuff, -object.CFrame.lookVector)

The thing is, this object is actually moving. So, my question is, when it goes to try and apply knockback does it

  1. See that I passed in -object.CFrame.lookVector, and go find it’s current value, or
  2. Use the value of -object.CFrame.lookVector at the time the function was called?
1 Like

The answer is #2, it will use the value of -object.CFrame.LookVector at the time the function was called. No property in Roblox can be passed by reference. On another note, since your object is moving, I recommend looking into raycast-based hit-detection. As the physics update loop slows in tandem with frame-rate, or the projectile’s displacements from the last frame become too large because of its velocity, the reliability of BasePart.Touched vastly declines. You won’t have to worry about network ownership abuse from exploiters either

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.