From the roblox wiki:

local tool = script.Parent
local user
script.Parent.Equipped:connect(function(mouse)
     mouse.Button1Down:connect(function()
          local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p -  tool.Handle.CFrame.p).unit*300)
          local hit, position = game.Workspace:FindPartOnRay(ray, user)
     end)
end)

A couple of things I'm unsure about:

  1. Why is there no value assigned to the var in line 2? I'm fairly new to scripting, and I thought all variables were supposed to have something assigned to them
  2. If user has no value assigned to it, why exactly is it the second parameter in the line 6 function?

2 comments

1

"empty variables" basically allow you to name a variable outside of another scope, making it visible to more scopers

0

When a variable is defined it will hold the value of nil, you do not need to set a variables value when it is created in Lua. This is probably done in this script so that you can easily add an ignore instance though the function its def to nil anyway.