Help with collisions?

Ok so i have “circles” so to speak that fall from the sky and i was wondering how you would set the floor to upon collision would remove the circles that hit it. Here is my code for the floor so far:

local floor = display.newRect(0, 0, \_W, 20);  
floor:setReferencePoint(display.CenterReferencePoint);  
floor.x = \_W/2; floor.y = 1000  
  
physics.addBody(floor, "static", {friction=0.3, bounce=0})  

Any help or link to a tutorial regarding this would help me a lot, thanks. [import]uid: 69054 topic_id: 18724 reply_id: 318724[/import]

[lua]local function onCollision(event)
if event.phase == “began”
if event.other.name == “ball” then
event.other:removeSelf()
event.other = nil
end
end
end
floor:addEventListener(“collision”, onCollision)[/lua]

just give your balls .name == “ball” parameter [import]uid: 16142 topic_id: 18724 reply_id: 71960[/import]

I inserted that and got this error in the terminal: ‘then’ expected near ‘if’ [import]uid: 69054 topic_id: 18724 reply_id: 71962[/import]

Oh i fixed it yay! you seem to have for got a ‘then’ next to “began” and thank you thats just what i needed! :slight_smile: [import]uid: 69054 topic_id: 18724 reply_id: 71969[/import]

sorry for mistype) [import]uid: 16142 topic_id: 18724 reply_id: 71976[/import]

lol no harm done. [import]uid: 69054 topic_id: 18724 reply_id: 72018[/import]