Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I get a tool to give me the name a brick when I click on it?

Asked by 6 years ago

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

0
What is script.Parent.Parent.Parent User#19524 175 — 6y
0
um you can just get the mouse.Target from the client theking48989987 2147 — 6y
0
@incapaz, first parent is tool, second parent is backpack, third parent is player. devisings 58 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You can basically put a value on a tree that its name is "IsTree" and check if it's there.

0
Thats not what im concerned about. In the script above I can't get the Part.Name, how do I do that? devisings 58 — 6y
Ad

Answer this question