How do I make a character variable for raycast?

I have no idea how I will get the character variable. And I am kind of a new scripter so how would this go about? My script is here:

local ray = Ray.new(script.Parent.HumanoidRootPart.Position, Vector3.new(0,0,-10))

–Create a ray that goes 5 studs in front of the character

local Part, Position = game.Workspace:FindPartOnRay(ray, script.Parent)

–Finds if there’s a part hit, and where the ray ends, while ignoring the character

if Part then

–do your stuff here

print(“Found part!”)

end

Instead of using FindPartOnRay, use FindPartOnRayWithIgnoreList… like this

local Part, Position = workspace:FindPartOnRayWithIgnoreList(ray, {script.Parent})
2 Likes