-
What do you want to achieve? I want to Destroy balls when they touch an Anchored “Collector” Part after falling & bouncing off a series of Anchored Parts.
-
What is the issue? The balls are created fine, and drop perfectly well, but when they hit the Collector the Touched function doesn’t fire.
-
What solutions have you tried so far?
Tried reading through the BasePart.Touched page and the Detecting Collisions pages but I’m a bit confused since it doesn’t really explain why it isn’t working in my application.
All the Parts involved have CanTouch true.
Theprint("Collector hit")
never prints in the Output window and there are no errors printed either.
I’ve also tried making the first line and the 2 functionslocal
but that didn’t help…
The script:
part1 = script.Parent
function ball(new)
prt.Name = "Ball"
prt.Shape = 0
prt.Material = "Neon"
prt.CustomPhysicalProperties = PhysicalProperties.new(2, .2, 0, 1, 1)
prt.Size = Vector3.new(4,4,4)
prt.BrickColor = BrickColor.new(math.random(0,1), math.random(0,1),math.random(0,1))
prt.Position = loc
prt.AssemblyLinearVelocity = Vector3.new(0,-100,0)
prt.CanCollide = true
prt.CanTouch = true
prt.Parent = workspace
end
function ontouch(hit)
print("Collector hit")
if hit.Name == ("Ball") then
hit.Destroy()
end
end
while true do
prt = Instance.new("Part")
loc = Vector3.new(math.random(-69.6,0.5),140,math.random(1065.2,1081.2))
wait(3)
ball()
prt = Instance.new("Part")
loc = Vector3.new(math.random(-141.7,-73.6),140,math.random(1065.2,1081.2))
wait(3)
ball()
prt = Instance.new("Part")
loc = Vector3.new(math.random(-213.8,-145.7),140,math.random(1065.2,1081.2))
wait(3)
ball()
end
part1.Touched:Connect (ontouch)
Explorer and Properties:
Thanks in advance for any help you can provide!