How to use Cframe projectiles that do damage?

Since .touched doesnt work with Cframe, I can’t make my projectiles work.

I know your going to say :GetTouchingParts() but there’s no tutorial on that whatsoever, the only ones I’ve found are 70 line long spaghetti code.
I’ve tried many things, sorry I can’t provide code because I’ve erased all of them.
I’ve tried touched, ofc it didnt work, tried gettouchingparts but I have no idea how to use it.
Tried cframe but I don’t understand how thats good for hit reg

Please help.

1 Like

.Touched is compatible with parts manipulated by CFrame values.

what exactly is a Cframe value? (im a noob at scripting)

A value which represents both positional and rotational information about an instance in the worldspace.

For projectiles you likely want to use raycasts.

I’m making a JJBA ( jojos bizarre adventure) game, there’s a thing named King Crimson which ability is to skip forwards in time, the reason I cant use raycast is because theres no way to skip forwards a raycast. The bullet is cframed by 10 forwards when a time skip happens.

(ps : I believe i solved the issue by welding a unanchored ball that serves as the hitbox to the bullet, I have yet to try this tho.)

magnitude works pretty well in my opinion

Aha but there is.

Well…in any case there are modules that deal with Raycast Hitboxes and Raycast projectiles.

:GetTouchingParts() is the way to go for your situation but it is completely fine if you don’t know how to use it. Me personally, I use it in my own game for accurate and fast hit events (because it is in fact faster than .Touched if used correctly)

I will give a brief explanation which hopefully helps you to achieve your goal.

Essentially, Part:GetTouchingParts() returns a table of other parts that the Part is touching but it requires a TouchInterest to work properly.

To get a TouchInterest in the part you first need create an empty .Touched event connection and put that in a variable (like so below)

local Connection = Part.Touched:Connect(function() end)

We put it in a variable so that you can :Disconnect() the Connection when you don’t need hit detection anymore so that there isn’t any lag

And then you need to make a loop that repeatedly checks if the part is touching anything (with :GetTouchingParts() of course)

Full Code:

local Connection = Part.Touched:Connect(function() end)

local Hit = false —This value is so we can stop the loop so it doesn’t repeat infinitely
while Hit == false do
  if Part:GetTouchingParts()[1] ~= nil then
    local Hum = Part:GetTouchingParts()[1].Parent:FindFirstChild(“Humanoid”)
    if Hum ~= nil then
      Hit = true
      Hum.Health -= —The amount of damage you want to deal
    end
  end
task.wait()
end
Connection:Disconnect()

If I read correctly you wanted to do damaging too so I also accounted for that in my code above.
One more thing, make sure to change “Part” in my code to the Part variable you have. Thanks

2 Likes

I will try this tommorow, thank you. (I’m a procrastinator, I know.)

Hi @kerosene0143 Have you given it a go?

Oh man, I entirely forgot about this.
Anyways, thank you. It works!

Cool! Remember to mark my post as the forum answer so that others know it’s already been solved.
Thanks.
harryw5

Already did right as I replied to you :wink:

CFrame, also Coordinate Frame ( X, Y, Z )

Think of it more as like, a 3D Coordinate Plane, thats really what it is.

Because I know exactly what that means.