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

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

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

7 comments

0

Are they touching or just adjacent?

0

They start of adjascent and then they touch

0

How are they touching?

0

When they are touching, they are are colliding..

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.

0

wtf is your problem idiot ^ it is 100% perfect sense and has all the info you can get...

0

i have no recollection of making this question but its funny to look back at lmao

2 answers

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.

1 comment

0

but the thing is... How will I make it so it print's the name of the part touching the other part...

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)

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