Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help making my RayCast aim down at the ground instead of where you look?

I am trying to make this ray aim down so i can find the part that's under you but it keeps only going in the direction of the lookVector.

This is what i have so far related to the Ray.

local torso = player.Character.HumanoidRootPart
		local ray = Ray.new(torso.CFrame.p, (torso.CFrame.lookVector + CFrame.fromEulerAnglesXYZ(0,math.rad(90),0 ).p)*100)
			local part, position = game.Workspace:FindPartOnRay(ray)		 
			print(part.Name)

I played around with it and tried different CFrame combos but it seems to not work and only go in the direction you're looking. I'm trying to angle it down at the ground.

1 answer

✓ Accepted answer

Try Changing The Angle From 90 To 270 This May Just Work By Flipping The Angles! (Be Sure To Upvote If this helped! :D) So The Code Will Look Like This:

local torso = player.Character.HumanoidRootPart
        local ray = Ray.new(torso.CFrame.p, (torso.CFrame.lookVector + CFrame.fromEulerAnglesXYZ(0,math.rad(270),0 ).p)*100)
            local part, position = game.Workspace:FindPartOnRay(ray)         
            print(part.Name)

4 comments

0

didn't help. Still gets the part i'm looking at.

0

Weird

0

worked, just had to switch like you said and do something a lil different. Thanks.

0

NP :D

This discussion is preserved as it was. New answers, comments, and votes are closed.