How do you get the CFrame of a workspace:Rayscast()?

I’m currently working on a blood system and i’m trying to make it so the blood splatters attach to the cframe of the raycast, in its current state it can stick only to floors just not on anything that is angled.

Current RayCasting code:

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
local t = {script.Parent, script.Parent.Parent}
params.FilterDescendantsInstances = t
local ray = workspace:Raycast(script.Parent.Position, Vector3.new(0,-1,0), params)

if ray then
	if ray.Instance.Anchored == true and ray.Instance.CanCollide == true then
		local s = game.ReplicatedStorage.BloodPuddle:Clone()
		s.Parent = script.Parent.Parent
		s.Color = script.Parent.Color
		s.Position = ray.Position
		script.Parent:Destroy()
	end
end
2 Likes

I am having the same problem as you. Trying to align an object to the surface it collided with.

Get the position normal:

This uses findpartonray, but with your use case you can use ray.Normal and ray.Position

2 Likes

I’ve been searching forever thankyou!

1 Like