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

Minigame Spawning Isn't Working?

Asked by 10 years ago

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

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

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)
Ad

Answer this question