My mouse.Hit.p is inaccurate? How do I make the aim more precise or did I mess something up?
When clicking, my script in a tool uses Target to make sure it is on a part. When it knows it's clicking a part, it goes on to use mouse.Hit.p to create a ray. The ray then makes sure that the part it hits is named after what I want it to be named, and then it fires an event. But, for some odd reason I cant wrap my head around I have to hold my mouse slightly above the part not on it, any explanation as to why or some other methods I could use that function easier or something?
Clip of the problem : https://gyazo.com/054208b4f6f8593b6ced986dfc15f920
The script in the tool:
01 | local Players = game:GetService( "Players" ) |
02 | local localPlayer = game.Players.LocalPlayer |
03 | local PartTransRequest = game.ReplicatedStorage:WaitForChild( "PartTransRequest" ) |
07 | local mouse = localPlayer:GetMouse() |
08 | local target = mouse.Target |
13 | script.Parent.Equipped:connect( function () |
17 | script.Parent.Unequipped:Connect( function () |
21 | mouse.Button 1 Down:connect( function () |
23 | local head = localPlayer.Character:FindFirstChild( "Head" ) |
24 | local rayOrigin = script.Parent.Handle.Position |
25 | local lookDirection = mouse.Hit.p |
30 | if Equipped = = true then |
34 | local ray = Ray.new(rayOrigin, lookDirection) |
37 | local hitPart, hitPosition = workspace:FindPartOnRay(ray) |
43 | if hitPart.Name = = "BOBJECT" then do |
44 | game.ReplicatedStorage.PartTransRequest:FireServer(hitPart) |