I’m making a bow and arrow system and the script below tells the arrow to anchor if it doesn’t match one of the names in the single-line if statements AND is also a magnitude of 2 or less.
script.Parent.Touched:Connect(function(hit)
if hit.Name == "Handle" then return end
if hit.Name == "Limb" then return end
if hit.Name == "Torso" then return end
if hit.Name == "bsp" then return end
if (hit.Parent:findFirstChild("Humanoid") ~= nil) then return end
script.Parent.CanCollide = true
print((hit.Position - script.Parent.Position).Magnitude)
if (hit.Position - script.Parent.Position).Magnitude < 2 then
print(hit.Name)
script.Parent.Anchored = true
wait(5)
script.Parent:Destroy()
end
end)
However, in this video, it shows the arrow anchoring way earlier than hitting the target. It does print the part it’s hit, in this case Target
, but it doesn’t anchor at the location.
While I post this, I might as well ask for help on how to rotate the arrow in the direction of the mouse.
Thanks!