How to make a part face the same way as another part's normal

Im trying to make a blood splatter script that uses raycasts to spawn a part with a blood splatter decal. However, the rotation does not seem to be working.

Here’s the code:

local BloodSplatterOrigin = workspace.BloodSplatterRaycastOrigin

while true do
	
	local xRange = 200
	local yRange = 200
	local zRange = 200

	local randomVector = Vector3.new(
		(math.random() - 0.5) * xRange,
		(math.random() - 0.5) * yRange,
		(math.random() - 0.5) * zRange
	)
	
local RaycastResult = workspace:Raycast(BloodSplatterOrigin.Position, randomVector)
	
if RaycastResult and RaycastResult.Instance then
	local BloodSplatter = game:GetService("ReplicatedStorage").Effects.BloodSplatter:Clone()
	BloodSplatter.Parent = workspace
	BloodSplatter.Position = RaycastResult.Position	
	BloodSplatter.Rotation = RaycastResult.Normal
end

	print(RaycastResult)
	task.wait(0.2)
end

The goal i want to achieve is that the blood part will be rotated parallel to the part’s surface.

1 Like

You use the cframe to make it point towards the normal direction

BloodSplatter.CFrame = CFrame.LookAt(RaycastResult.Position, RaycastResult.Position + RaycastResult.Normal)
2 Likes

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