Changing cframe to vector3 for raycasting

i am applying blood decals to limbs based on the side that lands on the floor however i am having issues with making sure that the raycast always points downwards.

local raycast = workspace:Raycast(bodypart.Position, (bodypart.CFrame.Position +, 1, 0) - bodypart.CFrame.Position),
1 Like

You can convert a CFrame value into a Vector3 value by simply wrapping the CFrame value with a like this:

local CFrameValue =, 0, 0)

local Result =
1 Like

this is returning nil, is this correct?

local raycast = workspace:Raycast(, - ( +,1,0)),

What is returning nil? The result of the raycast?

yes, the raycast is currently returning nil

You need to check for the raycast, aka the result. If the result is firing at the sky for example, it will return nil as the ray doesn’t hit anything and it can’t go forever.

Just add this simple if statement:

if Raycast then


this is still returning nil, i forgot to multiply the direction but it still doesnt work

local raycast = workspace:Raycast(, ( - +,-5,0)) * 3,

if you want to do a raycast facing downwards you should just do

yeah but during ragdoll the body parts will tumble and i can’t be sure it will be facing down

@LeqenDzTR is right, Raycasting is in worlspace, which means that,-1,0) will always be 1 stud downwards, regardless of the character’s orientation.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.