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
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.)
: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