How many times are you calling that function? If it is more than once, are you deleting the sprites or either setting them not active? Also, if you are calling this function more than once then you are reloading those images unnecessarily and using up memory. You can set up an image loading function and only call it once to avoid that.
Another thing, you are trying to enable physics on an image and not a sprite. Here are some changes I made:
Global buildLandMass as integer[5]
function loadAllImagesOnce()
groundImg = loadimage("groundSnow.png") //groundDirt for the original
dirtImg = loadimage("groundDirt.png")
endfunction
function Lego()
groundSpr = createsprite(groundImg)
SetSpritePhysicson(groundSpr, 1) // Static
for n = 1 to 5
buildLandMass[n] = createsprite(dirtImg)
SetSpritePhysicsOn(buildLandMass[n], 1)
next
SetSpritePosition(groundSpr,sW*3,sH - GetSpriteHeight(groundSpr))
SetSpritePosition(buildLandMass[1], getspritex(groundSpr) + GetSpriteWidth(groundSpr), sH - GetSpriteHeight(groundSpr))
SetSpritePosition(buildLandMass[2], getspritex(buildlandmass[1]) + GetSpriteWidth(buildLandMass[1]), sH - GetSpriteHeight(buildLandMass[1]))
SetSpritePosition(buildLandMass[3], getspritex(buildlandmass[2]) + GetSpriteWidth(buildLandMass[2]), sH - GetSpriteHeight(buildLandMass[1]))
SetSpritePosition(buildLandMass[4], getspritex(buildlandmass[3]) + GetSpriteWidth(buildLandMass[3]), sH - GetSpriteHeight(buildLandMass[1]))
SetSpritePosition(buildLandMass[5], getspritex(buildlandmass[4]) + GetSpriteWidth(buildLandMass[4]), sH - GetSpriteHeight(buildLandMass[1]))
endfunction
You could also do this with setspriteposition:
SetSpritePosition(groundSpr,sW*3,sH - GetSpriteHeight(groundSpr))
for i = 1 to 5
if i = 1
SetSpritePosition(buildLandMass[1], getspritex(groundSpr) + GetSpriteWidth(groundSpr), sH - GetSpriteHeight(groundSpr))
else
SetSpritePosition(buildLandMass[i], getspritex(buildlandmass[i-1]) + GetSpriteWidth(buildLandMass[i-1]), sH - GetSpriteHeight(buildLandMass[i-1]))
endif
next
It's handy if you want to create more sprites.