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

Why won't my script work?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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)
0
if anything, that would unanchor part1 instead of part2. You'd want to unanchor `script.Parent`instead of hit. ImageLabel 1541 — 9y
0
Part1 IS script.Parent. Besides, I think I figured it out. TealTeam 40 — 9y
0
Still unsolved! I thought I found the problem but it is not so! TealTeam 40 — 9y
1
put then on line 2. Also is part2 "Part2" or "part2". Capitolization matters. LostPast 253 — 9y
0
Why is nothing working? TealTeam 40 — 9y

3 answers

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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)
Ad
Log in to vote
0
Answered by 9 years ago

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)
Log in to vote
-1
Answered by
xuefei123 214 Moderation Voter
9 years ago
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

0
You forgot to call the function bro. UserOnly20Characters 890 — 9y

Answer this question