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

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

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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.

Ad

Answer this question