Use the following for the mouse, I think this would be a improvent and it is also better to use this for other aspects:
local Players = game:GetService("Players")
local localPlayer = Players.LocalPLayer
local mouse = localPlayer:GetMouse()
mouse.Button1Down:Connect(function()
local mouseHitCFrame = mouse.Hit --Now use this for the raycast
end)
Hope this helped you!
Sources:
https://developer.roblox.com/en-us/api-reference/class/Mouse