i followed a tutorial how to make a draggable part but how do i rotate it to face towards the player because right now i can move it but it doesnt rotate its also not setting anchored to false when you drop the part
-- Services
local uis = game:GetService("UserInputService")
local workspace = game:GetService("Workspace")
-- Variables
local picked_up_part = false
local part = nil
-- Input handler
uis.InputBegan:Connect(function(input)
local ray = workspace.CurrentCamera:ViewportPointToRay(uis:GetMouseLocation().X, uis:GetMouseLocation().Y)
if input.UserInputType == Enum.UserInputType.MouseButton1 and not picked_up_part then
for i, v in pairs(workspace:GetDescendants()) do
if v:HasTag("Item") and (ray.Origin + ray.Direction * (ray.Origin - v.Position).Magnitude - v.Position).Magnitude <= 1 then
picked_up_part = true
part = v
local connection = nil
connection = game:GetService("RunService").RenderStepped:Connect(function()
if not picked_up_part then connection:Disconnect() return end
local ray = workspace.CurrentCamera:ViewportPointToRay(uis:GetMouseLocation().X, uis:GetMouseLocation().Y)
part.Position = ray.Origin + ray.Direction * 10
part.Orientation = Vector3.new(0, 0, 0)
part.CanCollide = false
part.Anchored = false
end)
end
end
elseif input.UserInputType == Enum.UserInputType.MouseButton2 and picked_up_part then
-- Release the picked up part
picked_up_part = false
part.Anchored = true
part.CanCollide = true
part = nil
end
end)