I'm making a script that allows you to pick up certain parts by pressing 'E'. The object will then hover in front of the player's head (locked to their mouse as I tried to use the head and couldn't figure it out), and the player then can choose to drop it by pressing E again, like in Half-Life or Portal. But, I've hit a roadblock. The object will keep flying into the camera, and if the player points at the sky (for example), the object will go too far out. Basically, how can I lock it at a certain distance but maintain it's ability to follow the mouse? (Background info: Player will be in First Person)
local object
local Player = game.Players.LocalPlayer
local Character = Player.Character
local PlrMouse = Player:GetMouse()
local Camera = game.Workspace.CurrentCamera
while true do
wait()
while script.Parent.Grabbing.Value == true do
object = script.Parent.Obj.Value
object.CanCollide = false
wait()
rot = Vector3.new(PlrMouse.Hit.X, PlrMouse.Hit.Y, PlrMouse.Hit.Z)
object.Position = rot
end
end

2 comments
This is what happens: https://i.gyazo.com/7d0c882ec484b42980f9cec6ab3ba9a3.mp4
http://wiki.roblox.com/index.php?title=API:Class/Mouse