Hello, I see! It sounds like you’re trying to set the position of a hitbox relative to a rotating object, but you’re running into issues where the hitbox isn’t following the rotation properly or is being moved incorrectly.
If you’re trying to attach the hitbox to an object (like a sword) and make sure it moves with the object, especially when you want it to be rotated correctly, here’s the approach you can use. I’ll assume you’re dealing with a humanoid or character movement with a “dolphin” or some other object moving around.
Here’s an updated solution, taking rotation and position into account:
Solution
Copiar código
swordHitBox.CFrame = script.Parent.Handle.CFrame * CFrame.new(2, 0, 0)
This should work if you’re rotating the sword handle, and you want to move the hitbox relative to the handle. However, if it’s causing the character to move or is not updating as expected, here are a few checks to consider:
-
Check Anchoring: Ensure that the hitbox is anchored (or part of a model that’s anchored or follows the handle), especially if it’s supposed to remain static when not interacting with other parts. You can try to use
.Anchored = true
for parts, or set up constraints to keep it in place relative to the handle.
-
Make Sure You Are Modifying the Right Object: Double-check that you’re modifying the
CFrame
of the hitbox and not accidentally applying changes to the model or character itself. The CFrame
property of the hitbox needs to be set and updated in every frame to ensure it tracks the handle’s position and rotation correctly.
-
Moving with Rotation: If your hitbox is not following the rotation correctly, ensure that the offset you apply is always relative to the handle’s current position and rotation. The multiplication approach should ensure this, but if there’s any parent-child relationship or a body part involved, consider whether the object’s properties are overriding it.
Example:
If you’re rotating the sword and you want the hitbox to stay in place relative to the sword’s handle (with rotation), you would use something like this:
Copiar código
swordHitBox.CFrame = script.Parent.Handle.CFrame * CFrame.new(2, 0, 0)
This line will keep the hitbox
2 studs away from the sword handle along the X-axis, considering the handle’s current rotation.
Final Notes:
If the issue is more about the character movement (like a dolphin model), and you want to make sure that only the hitbox follows the sword, you can also ensure that the hitbox has a BodyPosition
or similar mechanism to keep its position correctly adjusted, but that depends on the context (like if the sword is attached to a moving character).
Let me know if this clears it up, or if you’re still seeing issues with the movement!