I am trying to make an axe be able to chop down wood but I'm struggling to figure out how to make sure if it clicks on a tree.
This is what I tried.
local playerName = script.Parent.Parent.Parent.Name
local Player = game.Players:WaitForChild(playerName)
local tool = script.Parent
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local maxDistance = 300
local BrickColor = BrickColor.new("Really red")
local function onActivation()
local Ray = Ray.new(tool.Handle.CFrame.p, (Mouse.Hit.p - tool.Handle.CFrame.p).unit * maxDistance)
local Part, Position = workspace:FindPartOnRay(Ray, Character, false, true)
local name = Part.Name
print(name)
end

3 comments
What is script.Parent.Parent.Parent
um you can just get the mouse.Target from the client
@incapaz, first parent is tool, second parent is backpack, third parent is player.