So I created a script for some minigames from a tutorial I watched. I decided to be original, so I also added a ScreenGui for the announcements. Originally, the script looked like this,
minigames = game.Lighting.Minigames:GetChildren() h = Instance.new("Hint") while true do if game.Players.NumPlayers > 1 then h.Text = "Deciding What Game To Play..." wait(3) rangame = math.random(1, #minigames) gamechosen = minigames [rangame] h.Text = "Game Chosen!" wait(2) h.Text = "We Are Playing:" ..gamechosen.Name wait(3) gamechosenclone = gamechosen:Clone() gamechosenclone.Parent = Workspace wait(3) spawns = gamechosenclone.Spawns:GetChildren() for i,v in pairs(game.Players:GetPlayers()) do name = v.Name check = Workspace:FindFirstChild(name) if check then checkhumanoid = check:FindFirstChild("Humanoid") if checkhumanoid then check:Moveto(spawns[i]) end end end for i = 3, 1, -1 do h.Text = "Game Begins In:" ..i wait(1) end for i = 10, 1, -1 do h.Text = "Time Left:" ..i end h.Text = "The Game Has Finished!" gamechosenclone:Destroy() else h.Text = "One Player Is Not Enough!" end wait(1) end
This script worked perfectly for me, and I was very happy, but then I added my own twist
minigames = game.Lighting.Minigames:GetChildren() GuiStatus = game.StarterGui.StatusBar.Main.Status while true do if game.Players.NumPlayers > 1 then GuiStatus.Text = "Deciding What Game To Play..." wait(3) rangame = math.random(1, #minigames) gamechosen = minigames [rangame] GuiStatus.Text = "Game Chosen!" wait(2) GuiStatus.Text = "We Are Playing:" ..gamechosen.Name wait(3) gamechosenclone = gamechosen:Clone() gamechosenclone.Parent = Workspace wait(3) spawns = gamechosenclone.spawns:GetChildren() for i,v in pairs(game.Players:GetPlayers()) do name = v.Name check = Workspace:FindFirstChild(name) if check then checkhumanoid = check:FindFirstChild("Humanoid") if checkhumanoid then check:MoveTo(spawns[i]) end end end for i = 3, 1, -1 do GuiStatus.Text = "Game Begins In:" ..i wait(1) end for i = 10, 1, -1 do GuiStatus.Text = "Time Left:" ..i end GuiStatus.Text = "The Game Has Finished!" gamechosenclone:Destroy() else GuiStatus.Text = "One Player Is Not Enough!" end wait(1) end
this was the new script, I created a textlabel, parented by a frame, parented by a screengui, under startergui. The script only displays "One Player Is Not Enough" on the screenGUI even if there are multiple players. The actual minigame script only runs up to the cloning of the minigame, then immediately stops and stays. It says "Unable to cast instance to Vector3". What should I fix? What have I done wrong? A link to the actual game here: http://www.roblox.com/Minigames-Bedrock-Alpha-place?id=14079887
You're only updating the gui in the StarterGui, not the guis for the players. The players will only see the changes when they respawn. Try this:
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 = 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
As for your other problem, check to make sure there isn't something called the name already in the Workspace that isn't a model