Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make a tool know what it's colliding with?

I'm trying to make it so this tool detects if it's hitting a certain object only.

local tool = script.Parent
local debounce = false
local mowevent = game.ReplicatedStorage.Remote.Mow
local pwr = 0.1
tool.Activated:Connect(function()
    if not debounce then
        debounce = true
        mowevent:FireServer(pwr)
workspace.Lawn.Grass.Touched:connect(function(tool)
  print("hit")
end)
wait(1)
debounce = false
    end
end)

Is there a better way to do this?

1 answer

###Put a separate server script.

#Server script inside Grass

script.Parent.Touched:Connect(function(part)
    if part.Parent.Name == "Mower" then -- if it’s a lawn mower
        -- Do code
    end
end)

###That should work.

This discussion is preserved as it was. New answers, comments, and votes are closed.