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

How to detect the touch of two seperate parts??

Asked by 4 years ago

Hi, i'm making a tycoon and i'm trying to work out how to detect the touching of two parts when the parts that the droppers dispense touch the collector at the end of the conveyor :/. I have tried .Touched, :GetTouchingParts, and looked endlessly at devforums and scripting helpers. I first tried this:

local Money = script.Parent.Parent.Parent.CashToCollect
 local Debris = game:GetService("Debris")


for i,v in pairs(script.Parent:GetChildren()) do
        if v.Name == "PartCollector" then
            v.Touched:connect(function(Part)
                if Part:FindFirstChild("Money") then
                    Money.Value = Money.Value + Part.Money.Value
                    Debris:AddItem(Part,0.1)
                end
            end)
        end
    end

There is a IntValue in each part that gets dispensed called 'Money'. The collector is meant to detect the part touching and find the IntValue and add it to another IntValue's Value. I then tried :GetTouchingParts and .Touched but this didn't work. Help please!

1 answer

Log in to vote
1
Answered by
NordicM 77
4 years ago
Edited 4 years ago

You should make it so instead of making the collector give you money when money touches it, you should make it so the money gives you money when it touches the collector. Hope you understand.

EDIT: You put a script inside of the money block and check when it touches the collector.

0
this should be a comment tbh Pupppy44 671 — 4y
Ad

Answer this question