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

How to make the script only execute when specific brick collides with other?

Asked by 6 years ago
Edited 6 years ago

So uhm, I'm having a big problemo and I was wondering how can I make the script only execute when the specific block is touched for example, if brick "center" from a Vehicle touches the brick that has the touchinterest line.

function onTouched(hit)
if debounce == false then
    debounce = true
    check = hit.Parent.Trucks1:FindFirstChild("Center") --this is where I get confused
    print ("Found TruckCenter")

    if check ~= nil then 

1 answer

Log in to vote
0
Answered by 6 years ago

Assuming you have your script in a part

local part = script.Parent

part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild('Trucks1'):FindFirstChild('Center') then
        -- Found it!
    end
end)

You can also test the name but I just copied what you writed on line 4 (I added findfirstchild on trucks though as it might not exist)

Ad

Answer this question