You're close, but you should try and test this yourself before asking here.
Just because the script editor shows no errors, it doesn't mean your code is bug free.
Anyways, here is the edited code:
connectionPart = pellet.Touched:connect(function(hit)
if hit then
tagPart(hit)
hit:BreakJoints()
connectionPart:disconnect()
end
end
I made this an anonymous function, since that is the only way I could think to have the function disconnect itself without using a form of debounce. This may or may not work as intended.
I removed the Part = hit line since it's unnecessary.
I removed the ~= nil because it's also unnecessary. (If hit is not nil, it will be 'truthy', so the if check will pass)
I removed the else because I assume you only want this to break a single part it hits.
By the way, this will still kill Players if it hits their characters. You'll have to add another check if you only want it to break the joints of specifically named Parts.
(BTW, use Tab instead of four spaces when writing code. It makes indentation easier to change.)
1 comment
Won't work - http://imgur.com/aZL8J5d