Need some help with math.random()

Hi, I’m quite new to scripting, and was wanting to test math.random(). I made a basic script to see if it would randomly load a map. And it looks like this:

local randmap = math.random(1,2)

wait(15)

if randmap == 1 then
	Game.Workspace.Map1.Transparency = 1
	Game.Workspace.Map1.CanCollide = true
	print("map1 was chosen")
end

if randmap == 2 then
	Game.Workspace.Map2.Transparency = 1
	Game.Workspace.Map2.CanCollide = true
	print("map2 was chosen")
end

Yet, when i test the game, both Map1 and Map2 just disappear from the workspace, I’m not really sure why this happens, so can someone explain it to me, maybe I am just using math,random() incorrectly.
My workspace looks like this:
234324

Thanks.

1 Like

Are the parts anchored? If they’re falling off the map as the place starts they would be destroyed

2 Likes

Thank you lol, I’ve always had a problem with anchoring, now I feel stupid.

2 Likes

I still forget sometimes and I’ve been using roblox studio for about 5 years now haha

2 Likes

Just to add on to this, here’s why.

https://developer.roblox.com/en-us/api-reference/property/Workspace/FallenPartsDestroyHeight

2 Likes