Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

MapChooser saying that :IsA is wrong?

It chooses a map to spawn out of ServerStorage but it wont work.

maps = {}
local maps = game.ServerStorage

	for i, v in pairs(maps:GetChildren())do
		if v:IsA("Model")then
			table.insert(maps, v.Name)
		end
	end

while true do
	randomMap = maps[math.random(1,#maps)]
	selectedMap = game.ServerStorage:WaitForChild(randomMap):Clone()
	selectedMap.Parent = game.Workspace
	wait(30)
	selectedMap:Destroy()
end

1 answer

✓ Accepted answer

:IsA() may not work with models, or maybe you used the wrong keyword. If this happens to me, I simply do the following:

maps = {}
local maps = game.ServerStorage

    for i, v in pairs(maps:GetChildren())do
        if v.ClassName==("Model") then
            table.insert(maps, v.Name)
        end
    end

while true do
    randomMap = maps[math.random(1,#maps)]
    selectedMap = game.ServerStorage:WaitForChild(randomMap):Clone()
    selectedMap.Parent = game.Workspace
    wait(30)
    selectedMap:Destroy()
end

If that doesnt work, try putting a space between ("Model") and then.

Hope I helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.