Help with raycast

You could fire it from parts created with attachments

Yeah, I did, Thats basically my broken hitbox script right now. And I dont want my script to look like this:

local ray = workspace:Ray(attach1, attath0 "stuff")
local ray2 = workspace:Ray(attach1, attath0 "stuff")
local ray3 = workspace:Ray(attach1, attath0 "stuff")
local ray4 = workspace:Ray(attach1, attath0 "stuff")
local ray5 = workspace:Ray(attach1, attath0 "stuff")
local ray6 = workspace:Ray(attach1, attath0 "stuff")
local ray7 = workspace:Ray(attach1, attath0 "stuff")

You can just try using the module its incredibly helpful, but its okay if you dont want to its your choice.

You could fire it from the weapon

What do you mean?
Fire the raycast from the blade?

That would just make it fire from the middle, making the whole top part of the blade… useless

No you could make attachments inside of the blade and fire from that.

Thats what it wouldl look like.

So does it work? If it does why would you want to change it. You havent exactly explained what part of it doesnt work also you have spelling mistakes second attach (attath

Raycasting is an engineering disaster. However, once you can wrangle it into doing what you want it to do, you’re pretty much set.

Also, the second argument should be a direction. You can get the direction by getting the LookVector of your two values and multiplying it by how far you want the raycast to go.

CFrame.new(startpos, endpos).LookVector * range

I use ray.Instance to make damage, detecting if the parent of the instance has a humanoid.
Instead of it looking like this:

if ray then
   if (ray.instance.name == "hieoieeeoeoioefoieiofoiejfoiwj") then
   end
end

it would look like this:

if ray then
   if (ray.instance.name == "hieoieeeoeoioefoieiofoiejfoiwj") then
   end
end
if ray2 then
   if (ray2.instance.name == "hieoieeeoeoioefoieiofoiejfoiwj") then
   end
end
if ray3 then
   if (ray3.instance.name == "hieoieeeoeoioefoieiofoiejfoiwj") then
   end
end
if ray4 then
   if (ray4.instance.name == "hieoieeeoeoioefoieiofoiejfoiwj") then
   end
end

So you need to detect if it has a humanoid?

This seems like a good idea… but how would I detect the endpos?

I already have that code. My problem is the ray firing.

if result then
local Hum = result.Instance.Parent:FindFirstChild(“Humanoid”)
if Hum then

I already have the code for that, lol

local direction = (mouse.Hit.Position - origin).Unit * MaxRayDistance You could just add lookvector to this and it would work

Here’s a tip. Instead of making a bunch of if statements, you can use a table to combine them all into one. I hope this helps you.

local rays = {ray,ray2,ray3,ray4}

for i = 1, #rays do
   local raym = rays[i]

   if (raym.instance.name == "hieoieeeoeoioefoieiofoiejfoiwj") then
   end
end

Oh. This seems helpful. I might try this tomorrow.

Just woke up. How would I try this?
I can use vector3, but that wouldnt make it go up relative to the front surface of the blade.

If I know how to use the CFrame stuff, my problem will be fixed because the raycasts are working now since I used the whole table thing