I’ve been trying for quite a while now to figure out how to make a part face the same side as a wall that a raycast hit. For some reason raycastresult.Normal doesn’t give the proper rotation of the wall.
I want the parts to look like this on different sides of the wall
Instead I get this
It seems nobody has had this problem before, because I tried to look up solutions but I got nothing related to this
Here’s the code for rotating the part:
mine.Orientation = char.HumanoidRootPart.Orientation
local ray3 = Ray.new((mine.CFrame * CFrame.new(0,0,1)).p,mine.CFrame.LookVector * 4)
local hit,pos = workspace:FindPartOnRayWithIgnoreList(ray3,{mine})
if hit then
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = {mine}
local rrray = workspace:Raycast(ray3.Origin,ray3.Direction,params)
--- "grounded" is just a variable that tells the script if the part landed on the ground or not
if grounded == false and rrray and rrray.Instance ~= mine and rrray.Instance.CanCollide == true and rrray.Instance.Parent:FindFirstChild("HumanoidRootPart") == nil then
mine.Orientation = Vector3.new(0,rrray.Normal.Y,0)
mine.CFrame = mine.CFrame * CFrame.Angles(math.rad(rrray.Normal.X),math.rad(rrray.Normal.Y),math.rad(rrray.Normal.Z))
end
end
“mine” is the part I want to rotate
I know it’s possible to do this because another game did it