Trouble with finding orientation of surfaces

I’m trying to create a “Note placement system”, I also want for the note object to rotate depending on the surface I’m hovering my mouse over.

I cannot seem to find a way to find the rotation it has to be on depending on the surface my mouse is hovering over

Here is the script I made, I made it very quickly, so if you see any bugs that may cause performance issues, don’t worry I have it covered.

local player = game.Players.LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")
local userInputService = game:GetService("UserInputService")
local tweenService =game:GetService("TweenService")
local runService = game:GetService("RunService")
--Placement
local mouse = player:GetMouse()
local currentPlace = nil
userInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		if not currentPlace then
			currentPlace = replicatedStorage.Assets.PlaceHolder:Clone()
			currentPlace.Parent=workspace
		else
			currentPlace:Destroy()
			currentPlace=nil
		end
	end
end)
mouse.Button1Down:Connect(function()
	if currentPlace then
		currentPlace:Destroy()
		currentPlace=nil
	end
end)
runService.Heartbeat:Connect(function()
	if currentPlace~=nil and mouse.Target then
		print(mouse.Target)
		tweenService:Create(currentPlace,TweenInfo.new(.2),{Position=mouse.Hit.p--[[, Orientation =]] }):Play()
		wait(.1)
	end	
end)

Get the normal surface of the part you’re looking at and orient the note to face that vector. You can do this with Mouse.TargetSurface, but it won’t work on complex shapes/meshes, so you should use raycasts instead. This particular problem has been asked numerous times here on the forum, here’s an older thread related to your issue:

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