i have made a cannon that fires a ball, however i want the ball to anchor when it hits the basepart, however it only fires when it touches me
the code as follows is placed in a script in the part
script.Parent.Touched:Connect(function(hit) if hit.Name == "Baseplate" then script.Parent.Anchored = true end end)
Not sure what you really mean here. "it only fires when it touches me" if you mean for it to fire when you do something else like clicking it your script should be like:
1, put a click detector in the part
script.Parent.ClickDetector.MouseClick:Connect(function(hit) if hit.Name == "Baseplate" then script.Parent.Anchored = true end end)
Touched event doesn't fire when two anchored parts touch. That means you have to use hinge to keep the part in place and the touch event to work.