local part = script.Parent local part2 = script.Parent.Parent.Specificpart local function onTouch(part) print("Touch started: " .. part.Name) part2.Size = Vector3.new(4,4,4) end local function onTouchEnded(part) print("Touch ended: " .. part.Name) part2.Size = Vector3.new(1,4,1) end part.Touched:Connect(onTouch) part.TouchEnded:Connect(onTouchEnded)
when i someone touching "part" then"part2" changes his size i want - part2 touches part and part2 changing his size how i check part2 touching part
To do this you need to add what is called an if statement. An if statement checks whether an argument is true or false.
Here is what you would do:
local part = script.Parent local part2 = script.Parent.Parent.Specificpart local function onTouch(part) print("Touch started: " .. part.Name) if part == part2 then print("Part is the same") end part2.Size = Vector3.new(4,4,4) end local function onTouchEnded(part) print("Touch ended: " .. part.Name) part2.Size = Vector3.new(1,4,1) end part.Touched:Connect(onTouch) part.TouchEnded:Connect(onTouchEnded)
You can get the hitted part's name:
script.Parent.Touched:Connect(function(hit) if hit.Name == "Part2" then hit.Size = Vector3.new(4,4,4) end end) script.Parent.TouchEnded:Connect(function(hit) if hit.Name == "Part2" then hit.Size = Vector3.new(1,4,1) end end)
Hope this helped!