I am trying to make a gathering tool, to take a part that the player clicks on while the tool is equipped, and if certain specifications are met, such as the name of the part, then it starts the animation and etc. However for now I am just trying to determine how to get the script to print the name of the part that the player clicks on.
local function getmouse() -- this code i got from a help question, never used rays before
local cursorPosition = game:GetService("UserInputService"):GetMouseLocation()
local oray = game.workspace.CurrentCamera:ViewportPointToRay(cursorPosition.x, cursorPosition.y, 0)
local ray = Ray.new(game.Workspace.CurrentCamera.CFrame.p,(oray.Direction * 1000))
return workspace:FindPartOnRay(ray)
end
script.Parent.Activated:Connect(function() -- script.Parent is a tool
print(getmouse());
end)

1 comment
is the script a Local Script?