Ad
Log in to vote
0

Roblox Studio Script Supposed To Spawn Twelve Models Every Eight Minutes.. Not Working?

Asked by 14 days ago

Hello! I am currently trying to make a Roblox Script that randomly takes twelve Models out of a folder, and then puts them into twelve positions. Then, after eight minutes, this should repeat again. Also, every time I test it, the models do not have the same rotation as they did and sometimes, one model will spawn, and others, four will spawn. Here is the code:

local folder = game.Workspace.Folder
local positions = {
    Vector3.new(-161.467, 21.193, -47.034),
    Vector3.new(-315.967, 21.193, -47.034),
    Vector3.new(-470.55, 21.193, -47.034),
    Vector3.new(-625.132, 21.193, -47.034),
    Vector3.new(-779.714, 21.193, -47.034),
    Vector3.new(-934.297, 21.193, -47.034),
    Vector3.new(-1088.879, 21.193, -47.034),
    Vector3.new(-1243.462, 21.193,- -47.034),
    Vector3.new(-1398.044, 21.193, -47.034),
    Vector3.new(-1552.626, 21.193, -47.034),
    Vector3.new(-1707.209, 21.193, -47.034),
    Vector3.new(-1861.792, 21.193, -47.034)
}

local function placeModels()
    local models = folder:GetChildren()
    local selectedModels = {}
    for i = 1, 12 do
        local randomIndex = math.random(1, #models)
        local model = models[randomIndex]
        table.remove(models, randomIndex)
        table.insert(selectedModels, model)
    end
    for i, model in ipairs(selectedModels) do
        model.Parent = game.Workspace
        model:SetPrimaryPartCFrame(CFrame.new(positions[i]))
    end
end

placeModels()
while true do
    wait(8*60)
    placeModels()
end

I do not know why this is not working and have not yet received any error messages in the output. By the way, if there is any advanced script that is looking for work, DM me on discord @Kitt #4357.

Answer this question