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

Trying to make a part touch another part not working???

Asked by 7 years ago
Edited 7 years ago

I just don't realize why this is not working... i have a part and i have another part with this script but it seems to not work...

script.Parent.Touched:connect(function(ThisPart) -- first part
    if ThisPart.Parent.Name == "Item" then
        print("Part touch another part")
    else
        print(ThisPart.Parent.Name)
    end
end)

But it always prints the players name

0
Are they touching or just adjacent? hiimgoodpack 2009 — 7y
0
They start of adjascent and then they touch greatneil80 2647 — 7y
0
How are they touching? hiimgoodpack 2009 — 7y
0
When they are touching, they are are colliding.. greatneil80 2647 — 7y
View all comments (3 more)
0
Not enough detail to answer the question. The problem doesn't have to do with the script, I find, so the issue doesn't seem to be directly a scripting issue. You're probably just missing some logic here. Not enough information to answer. CootKitty 311 — 7y
0
wtf is your problem idiot ^ it is 100% perfect sense and has all the info you can get... greatneil80 2647 — 7y
0
i have no recollection of making this question but its funny to look back at lmao greatneil80 2647 — 3y

2 answers

Log in to vote
0
Answered by 7 years ago

It keeps printing the players name for only 1 reason. You're putting "ThisPart.Parent.Name". The parameter of this function gives you the part that touched the part. The parent of ThisPart is the actual player. ThisPart's parent would be the player. Get rid of the parent when printing when you printed.

0
but the thing is... How will I make it so it print's the name of the part touching the other part... greatneil80 2647 — 7y
Ad
Log in to vote
0
Answered by 3 years ago

The actual solution if someone stumbles across this trash:

parts gotta be unanchored or you gotta use gettouchingparts or you can use this trashy code i made:

local GetTouched = {}
local function GetTouchingParts(part,func)
    print('checked')
    local connection = part.Touched:Connect(function() end)
    local results = part:GetTouchingParts()
    connection:Disconnect()
    return results
end
local TouchedList = {}
TouchedList.__index = TouchedList
function GetTouched.new(part,func)
    print('set')
    local returned = setmetatable(GetTouched,TouchedList)
    part:GetPropertyChangedSignal("Position"):Connect(function()
        if #GetTouchingParts(part) == 0 then else
            returned = GetTouchingParts(part)
            TouchedList[part] = returned
        end
    end)
    part:GetPropertyChangedSignal("Size"):Connect(function()
        if #GetTouchingParts(part) == 0 then else
            returned = GetTouchingParts(part)
            TouchedList[part] = returned
        end
    end)
    local meta = setmetatable(TouchedList,{
        __index = GetTouched,
        __newindex = function(a,b,c)
            func()
        end
    })
end

GetTouched.new(script.Parent, function()
    print('hello')
end)

Answer this question