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)