Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

MapChooser saying that :IsA is wrong?

Asked by
Nidoxs 190
8 years ago

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

Log in to vote
0
Answered by 8 years ago

: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.

Ad

Answer this question