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

Minigame Spawning Isn't Working?

Someone helped me on my last main problem for my script, but his answer for my second problem didn't work.

local minigames = game.Lighting.Minigames:GetChildren()

local GuiStatus = game.StarterGui.StatusBar.Main.Status
function updateGui(text)
    GuiStatus.Text = text
    for i,v in ipairs(game.Players:GetPlayers()) do
        pcall(function()
            v.PlayerGui.StatusBar.Main.Status.Text = text
        end)
    end
end
while true do
    if game.Players.NumPlayers > 1 then
        updateGui("Deciding What Game To Play...")
        wait(3)
        rangame = math.random(1, #minigames)
        gamechosen = minigames[rangame]
        updateGui("Game Chosen!")
        wait(2)
        updateGui(("We Are Playing:" ..gamechosen.Name))
        wait(3)
        gamechosenclone = gamechosen:Clone()
        gamechosenclone.Parent = Workspace
        wait(3)
        local spawns = gamechosenclone.spawns:GetChildren()
        for i,v in pairs(game.Players:GetPlayers()) do
            local name = v.Name
            local check = game.Workspace:FindFirstChild(name)
            if check then
                local checkhumanoid = check:FindFirstChild("Humanoid")
                if checkhumanoid then
                    check:MoveTo(spawns[i])
                end
            end
        end
        for i = 3, 1, -1 do
            updateGui(("Game Begins In:" ..i))
            wait(1)
        end
        for i = 10, 1, -1 do
        updateGui(("Time Left:" ..i))
        end
        updateGui("The Game Has Finished!")
        gamechosenclone:Destroy()
    else
        updateGui("One Player Is Not Enough!")
    end
    wait(1)
end

This script controls a Gui, some minigames, and the spawning into the minigame. The problem is, it is not spawning me into my minigame when I want it to. It says "Unable to cast instance to Vector3" I double checked to make sure there is nothing called "name" in the Workspace.

1 answer

✓ Accepted answer

MoveTo() takes a Vector3 value. Therefore you cannot give it an object, which is what you're doing (it's different with humanoids, but that does not matter right now). So, give it the object's position, not the object.

check:MoveTo(spawns[i].Position)

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