local player = game.Players.LocalPlayer local mouse = player:GetMouse() local toggle = false mouse.KeyDown:connect(function(key) if not toggle and key == "r" then local i = Instance.new("Part",workspace) i.Size = Vector3.new(14.53, 11.41, 1.59) i.Anchored = true while true do wait() i.Position = mouse.Hit.Position end end end)
1.) KeyDown is deprecated, use UserInputService or ContextActionService.
2.) The way mouse.Hit is calculated is with a ray, which is the UnitRay property, and gets the position where the ray and a BasePart instersect. This is why the part comes up to your camera. Your solution is to set the Mouse's TargetFilter to the part you want to move.
mouse.TargetFilter = i