I am tryng to build a collision between 3 objects.A laser beam,a cow and a cowboy. All good,but when the collision it is fired,it gives me an error that says “attepmt to index field ‘target’ a nil value”.The target is the beam,but how do I declare it? Thank you!
local function onCollision (event) local cowOne = cow() cowOne.type = "cowOne" cowOne.collision = onCollision beam.type = "beam" beam.collision = onCollision if event.phase == "began" then if event.target.type == "beam" and event.other.type == "cowOne" then print ("You hit a cow") else print ("You hit a cowboy") end end end