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)
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
You forgot to call the function bro.
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
if anything, that would unanchor part1 instead of part2. You'd want to unanchor
script.Parentinstead of hit.Part1 IS script.Parent. Besides, I think I figured it out.
Still unsolved! I thought I found the problem but it is not so!
put then on line 2. Also is part2 "Part2" or "part2". Capitolization matters.
Why is nothing working?