Hello i am trying to make a ray but in line 7 an error occurs
Script:
local part = script.Parent
local Lazar = game.ReplicatedStorage.Lazar
local myFirstRay = Ray.new(part.Position, Vector3.new(0,0, -1024))
while wait() do
local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(myFirstRay, part, Lazar)
local Lazar = script.Parent
local Part = game.Workspace.TwistedPandora.Part
local X = Part.Position.X
local Y = Part.Position.Y
local Z = Part.Position.Z + -512
Lazar.Position = Vector3.new(X,Y,Z)
if hit then
print("Ray intersected with another part!")
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
elseif hit.Parent.Parent:FindFirstChild("Humanoid") then
hit.Parent.Parent.Humanoid.Health = 0
else
hit:Destroy()
end
end
end

1 comment
The 3rd and 4th parameters on FindPartOnRay are boolean values. The 3rd parameter is Terrrain Are Cubes and the 4th is ignore water.