I am trying to make it so that when part1 touches part2, part2 unanchors. Here is the script:
function onTouched(hit) if hit.Name=="Part2" then hit.Anchored=false end end script.Parent.Touched:connect(onTouched)
By your description.. " ... when part1 touches part2, part2 unanchors. " then it sounds like you don't want to be unanchoring what hit script.Parent
, you wanna check that what hit it IS Part2 then unanchor script.Parent
(Part1)
script.Parent.Touched:connect(function(hit) if hit.Name=="Part2" then script.Parent.Anchored = false end end)
Okay, simple answer. Hit is something that is put into whatever hit it, so i believe hit.Parent.Name would work instead of hit.Name.
function onTouched(hit) if hit.Parent.Name=="Part2" then hit.Parent..Anchored=false end end script.Parent.Touched:connect(onTouched)
function onTouched(hit) if hit.Name == "Part2" then--change "Part2" to exact name of part hit.Anchored = false else print("Not the part") end end
No problem