How can I silence these errors?

I’ve made a script and it all runs beautifully with zero errors. Even though it looks as if there are errors.
Here’s what I mean:


Again the script returns zero errors when playtesting.
How can I silence these error lines when in the script?
Here is the code:

--//Main Menu Gui//
local mainMenu = {}

--[Services]
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")

--[Variables]
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local AssetsFolder = ReplicatedStorage:WaitForChild("Assets")
local ModulesFolder = ReplicatedStorage:WaitForChild("ClientModules")

--[Modules]
local Images = require(AssetsFolder:WaitForChild("Images"))
local Audio = require(AssetsFolder:WaitForChild("Audio"))
local Utilities = require(ModulesFolder:WaitForChild("Utilities"))
local PlayerData = require(ModulesFolder:WaitForChild("PlayerData"))

local createObject = Utilities.CreateObject
local playSound = Utilities.PlaySound
local tween = Utilities.Tween

local UIBlip = createObject("Sound", {
	SoundId = ("rbxassetmenuLabelid://"..Audio.SmallBlip),
	Name = "MenuBlip", Volume = 0.4,
	Parent = workspace:WaitForChild("AudioContainer")
})
--[[
	||Checkpoint #1
	--
	||Miscellaneous
--]]

local function CreateMenuItems(itemTable)
	for i, item in pairs(itemTable) do
		createObject("ImageButton", {
			BackgroundTransparency = 0.5,
			BackgroundColor3 = Color3.new(0.631373, 0.631373, 0.631373),
			Size = UDim2.new(1, 0, 1, 0),
			Image = ("rbxassetid://"..Images[item.."Button"]),
			Name = item, ZIndex = 3, Parent = itemContainer,
			createObject ("UICorner", {
				CornerRadius = UDim.new(1, 0)
			}),
			createObject ("UIStroke", {
				Color = Color3.new(0, 0, 0),
				Thickness = 2
			}),		
			MouseButton1Down = function()
				menuLabel.Text = ""
				cursor.Rotation = 0
				--[Crap ton of tweening and it looks ugly but whatever]
				tween(topLabel, {Position = UDim2.new(Utilities.IsMobile() and 0 or -1, 0, Utilities.IsMobile() and -1 or 0, Utilities.IsMobile() and 0 or 40)}, 0.5, "Quart", "InOut")
				tween(versionLabel, {Position = UDim2.new(0, -20, 1, 0)}, 0.5, "Quart", "InOut")
				tween(cursor, {Position = UDim2.new(0.425, 0, 2, 0), Rotation = 180}, 0.5, "Back", "InOut")
				tween(arrowRight, {Position = UDim2.new(1, 0, 0, 0)}, 0.5, "Quart", "InOut")
				tween(arrowLeft, {Position = UDim2.new(0, -30, 0, 0)}, 0.5, "Quart", "InOut")
				task.wait(0.5)
				tween(itemFrame, {Position = UDim2.new(0, 0, 1, 0)}, 1.5, "Quart", "InOut")
				tween(uiPageLayout, {Padding = UDim.new(1, 0)}, 1.5, "Back", "InOut")
				tween(id, {Position = UDim2.new(0.15, 0, -1, 0)}, 1.5, "Quart", "InOut")
				task.wait(1.5)
				if item == "Continue" then
					local faderBackground = createObject("Frame", {
						BackgroundColor3 = Color3.new(0, 0, 0),
						Size = UDim2.new(1, 0, 1, 0),
						BackgroundTransparency = 1,
						ZIndex = 5, Parent = gui
					})
					local mainMenuOST = workspace:WaitForChild("AudioContainer"):WaitForChild("MainMenu")
					tween(faderBackground, {BackgroundTransparency = 0}, 2)
					tween(mainMenuOST, {Volume = 0}, 2)
					task.wait(2)
					mainMenuOST:Remove()
					if PlayerData.CompletedEvents ~= nil then
						--Continue code
					else
						local IntroScript = ModulesFolder:WaitForChild("IntroScript")
						tween(faderBackground, {BackgroundTransparency = 1}, 2)
						IntroScript:Chapter1Opening()
					end
				else
					--Code
				end
			end
		})
	end
end

local function UpdatePage()
	for i, object in pairs(itemContainer:GetChildren()) do
		if object:IsA("ImageButton") then
			object.BackgroundColor3 = Color3.new(0.258824, 0.258824, 0.258824)
			object:WaitForChild("UIStroke").Color = Color3.new(0, 0, 0)
		end
	end
	uiPageLayout.CurrentPage.BackgroundColor3 = Color3.new(0.631373, 0.631373, 0.631373)
	uiPageLayout.CurrentPage:WaitForChild("UIStroke").Color = Color3.new(1, 1, 1)
	for i = 1, #uiPageLayout.CurrentPage.Name, 1 do
		menuLabel.Text = string.sub(uiPageLayout.CurrentPage.Name, 1, i)
		task.wait(0.03)
	end
end

--[[
	||Checkpoint #2
	--
	||Initiate Main Menu
--]]
function mainMenu:Init()
	--[[
		||Checkpoint #1
		--
		||Creating and Fading Gui In
	--]]
	gui = Instance.new("ScreenGui", PlayerGui)
	gui.Name = "MainMenu"
	gui.IgnoreGuiInset = true
	
	do		
		local faderBackground = createObject("Frame", {
			BackgroundColor3 = Color3.new(0, 0, 0),
			Size = UDim2.new(1, 0, 1, 0),
			ZIndex = 10, Parent = gui
		})		
		local backgroundImages = {
			Images.MainMenuBackground1,
			Images.MainMenuBackground2
		}		
		local Background = createObject("ImageLabel", {
			Image = ("rbxassetid://"..backgroundImages[math.random(1,#backgroundImages)]),
			Size = UDim2.new(1, 0, 1, 0),
			ZIndex = 1, Parent = gui
		})
		if not Background.IsLoaded then
			repeat task.wait() until Background.IsLoaded
		end
		playSound(Audio.MainMenu, nil, nil, true, "MainMenu")
		tween(faderBackground, {BackgroundTransparency = 1}, 2)
		task.wait(2)
		faderBackground:Remove()
	end

	--[[
		||Checkpoint #2
		--
		||Creating other Objects
	--]]
	do
		itemFrame = createObject("Frame", {
			BackgroundColor3 = Color3.new(0, 0, 0),
			BackgroundTransparency = 0.5,
			Size = UDim2.new(1, 0, 0.275, 0),
			Name = "ItemFrame",
			Position = UDim2.new(0, 0, 1, 0),
			ZIndex = 2, Parent = gui,
			createObject("UIGradient", {
				Transparency = NumberSequence.new({
					NumberSequenceKeypoint.new(0, 1),
					NumberSequenceKeypoint.new(0.4, 0),
					NumberSequenceKeypoint.new(0.6, 0),
					NumberSequenceKeypoint.new(1, 1)
				})
			}),
			
			createObject("ImageLabel", {
				BackgroundTransparency = 1,
				Size = UDim2.new(1.1, 0, 1.1, 0),
				Position = UDim2.new(0.425, 0, 2, 0),
				SizeConstraint = Enum.SizeConstraint.RelativeYY,
				Image = ("rbxassetid://"..Images.ButtonCursor),
				Name = "Cursor", ZIndex = 4,
			}),
			
			createObject("Frame", {
				BackgroundTransparency = 1,
				Size = UDim2.new(1, 0, 1, -10),
				SizeConstraint = Enum.SizeConstraint.RelativeYY,
				Name = "ItemContainer",
				Position = UDim2.new(0.5, 0, 0.5, 0),
				AnchorPoint = Vector2.new(0.5, 0.5),
				ZIndex = 2,

				createObject("UIPageLayout", {
					EasingStyle = Enum.EasingStyle.Quint,
					TweenTime = 0.5,
					Padding = UDim.new(1, 0),
					HorizontalAlignment = "Center",
					VerticalAlignment = "Center",
					SortOrder = Enum.SortOrder.LayoutOrder,
					Circular = true
				})
			})
		})
		
		menuLabel = createObject("TextLabel", {
			BackgroundTransparency = 1,
			Size = UDim2.new(1, 0, 07, 0),
			Name = "MenuLabel",
			Font = Enum.Font.PatrickHand,
			TextScaled = true,
			Text = "",
			TextColor3 = Color3.new(1, 1, 1),
			Position = UDim2.new(0, 0, 0.55, 0),
			ZIndex = 2, Parent = gui,

			createObject("UIStroke", {
				Color = Color3.new(0, 0, 0),
				Thickness = 2
			})
		})
		
		id = createObject("Frame", {
			BackgroundTransparency = 0.3,
			BackgroundColor3 = Color3.new(1, 1, 1),
			Size = UDim2.new(0.70, 0, 0.400, 0),
			Name = "PlayerID",
			Position = UDim2.new(0.15, 0, -1, 0),
			ZIndex = 2, Parent = gui,

			createObject("UIStroke", {
				Color = Color3.new(0, 0, 0),
				Thickness = 2
			}),

			createObject("UICorner", {
				CornerRadius = UDim.new(0.1, 0)
			}),

			createObject("Frame", {
				BackgroundTransparency = 1,
				SizeConstraint = Enum.SizeConstraint.RelativeYY,
				Size = UDim2.new(0.7, 0, 0.7, 0),
				Name = "IconContainer",

				createObject("ImageLabel", {
					BackgroundTransparency = 1,
					Image = ("rbxassetid://"..Images[PlayerData.PlayerPokemon]),
					ImageRectSize = Vector2.new(160, 160),
					Size = UDim2.new(0.9, 0, 0.9, 0),
					Position = UDim2.new(0.05, 0, 0.05, 0),
					Name = "Icon", ZIndex = 3.0,

					createObject("UIStroke", {
						Color = Color3.new(0, 0, 0),
						Thickness = 2
					}),

					createObject("UICorner", {
						CornerRadius = UDim.new(Utilities.IsMobile() and 0.3 or 0.2, 0)
					})
				}),
			}),

			createObject ("Frame", {
				BackgroundColor3 = Color3.new(0, 0, 0),
				BackgroundTransparency = 0.5,
				BorderSizePixel = 0,
				Size = UDim2.new(0.7, 0, 0.45, 0),
				Position = UDim2.new(0.29, 0, 0.1, 0),
				Name = "Badges", ZIndex = 3.0
			}),

			createObject("Frame", {
				BackgroundColor3 = Color3.new(0, 0, 0),
				BackgroundTransparency = 0.5,
				BorderSizePixel = 0,
				Size = UDim2.new(1, 0, 0.25, 0),
				Position = UDim2.new(0, 0, 0.7, 0),
				Name = "Data", ZIndex = 3.0,

				--[Text Objects for "Name:"]
				createObject("TextLabel", {
					BackgroundTransparency = 1,
					Size = UDim2.new(0.125, 0, 0.50, 0),
					Position = UDim2.new(0, 0, 0.25, 0),
					Font = Enum.Font.PatrickHand,
					TextXAlignment = Enum.TextXAlignment.Right,
					Text = "Name:", TextScaled = true,
					TextColor3 = Color3.new(1, 1, 1),
					Name = "NameCaption", ZIndex = 4,

					createObject("UIStroke", {
						Color = Color3.new(0, 0, 0),
						Thickness = 2
					})
				}),

				createObject("TextLabel", {
					BackgroundTransparency = 1,
					Size = UDim2.new(0.125, 0, 1, 0),
					Position = UDim2.new(0.125, 0, 0, 0),
					Font = Enum.Font.PatrickHand,
					TextXAlignment = Enum.TextXAlignment.Left,
					Text = PlayerData.PlayerName, TextScaled = true,
					TextColor3 = Color3.new(1, 1, 1),
					Name = "NameLabel", ZIndex = 4,

					createObject("UIStroke", {
						Color = Color3.new(0, 0, 0),
						Thickness = 2
					})
				}),

				--[Text Objects for "Team:"]
				createObject("TextLabel", {
					BackgroundTransparency = 1,
					Size = UDim2.new(0.125, 0, 0.50, 0),
					Position = UDim2.new(0.25, 0, 0.25, 0),
					Font = Enum.Font.PatrickHand,
					TextXAlignment = Enum.TextXAlignment.Right,
					Text = "Team:", TextScaled = true,
					TextColor3 = Color3.new(1, 1, 1),
					Name = "TeamCaption", ZIndex = 4,

					createObject("UIStroke", {
						Color = Color3.new(0, 0, 0),
						Thickness = 2
					})
				}),

				createObject("TextLabel", {
					BackgroundTransparency = 1,
					Size = UDim2.new(0.125, 0, 1, 0),
					Position = UDim2.new(0.375, 0, 0, 0),
					Font = Enum.Font.PatrickHand,
					TextXAlignment = Enum.TextXAlignment.Left,
					Text = PlayerData.Team, TextScaled = true,
					TextColor3 = Color3.new(1, 1, 1),
					Name = "TeamLabel", ZIndex = 4,

					createObject("UIStroke", {
						Color = Color3.new(0, 0, 0),
						Thickness = 2
					})
				}),

				--[Text Objects for "Chapter:"]
				createObject("TextLabel", {
					BackgroundTransparency = 1,
					Size = UDim2.new(0.125, 0, 0.50, 0),
					Position = UDim2.new(0.5, 0, 0.25, 0),
					Font = Enum.Font.PatrickHand,
					TextXAlignment = Enum.TextXAlignment.Right,
					Text = "Chapter:", TextScaled = true,
					TextColor3 = Color3.new(1, 1, 1),
					Name = "ChapterCaption", ZIndex = 4,

					createObject("UIStroke", {
						Color = Color3.new(0, 0, 0),
						Thickness = 2
					})
				}),

				createObject("TextLabel", {
					BackgroundTransparency = 1,
					Size = UDim2.new(0.125, 0, 1, 0),
					Position = UDim2.new(0.625, 0, 0, 0),
					Font = Enum.Font.PatrickHand,
					TextXAlignment = Enum.TextXAlignment.Left,
					Text = PlayerData.Chapter, TextScaled = true,
					TextColor3 = Color3.new(1, 1, 1),
					Name = "ChapterLabel", ZIndex = 4,

					createObject("UIStroke", {
						Color = Color3.new(0, 0, 0),
						Thickness = 2
					})
				}),

				--[Text Objects for "Play Time:"]
				createObject("TextLabel", {
					BackgroundTransparency = 1,
					Size = UDim2.new(0.125, 0, 0.5, 0),
					Position = UDim2.new(0.75, 0, 0.25, 0),
					Font = Enum.Font.PatrickHand,
					TextXAlignment = Enum.TextXAlignment.Right,
					Text = "TimePlayed:", TextScaled = true,
					TextColor3 = Color3.new(1, 1, 1),
					Name = "TimePlayedCaption", ZIndex = 4,

					createObject("UIStroke", {
						Color = Color3.new(0, 0, 0),
						Thickness = 2
					})
				}),

				createObject("TextLabel", {
					BackgroundTransparency = 1,
					Size = UDim2.new(0.125, 0, 1, 0),
					Position = UDim2.new(0.875, 0, 0, 0),
					Font = Enum.Font.PatrickHand,
					TextXAlignment = Enum.TextXAlignment.Left,
					Text = PlayerData.TimePlayed, TextScaled = true,
					TextColor3 = Color3.new(1, 1, 1),
					Name = "TimePlayedLabel", ZIndex = 4,

					createObject("UIStroke", {
						Color = Color3.new(0, 0, 0),
						Thickness = 2
					})
				}),
			})
		})
		itemContainer = itemFrame:WaitForChild("ItemContainer")
		cursor = itemFrame:WaitForChild("Cursor")
		uiPageLayout = itemContainer:WaitForChild("UIPageLayout")
	end
	
	local menuItems = {
		"Continue",
		"DeleteSave",
		"ChangeNames",
		"Help",
		"Jukebox",
		"Settings",
	}
	
	CreateMenuItems(menuItems)
	tween(itemFrame, {Position = UDim2.new(0, 0, 0.65, 0)}, 1.5, "Quart", "Out")
	tween(uiPageLayout, {Padding = UDim.new(0.3, 0)}, 1.5, "Back", "Out")
	tween(id, {Position = UDim2.new(0.15, 0, 0.15, 0)}, 1.5, "Quart", "Out")
	task.wait(1)
	tween(cursor, {Position = UDim2.new(0.425, 0, -0.05, 0), Rotation = 180}, 1.5, "Quart", "Out")
	tween(uiPageLayout, {Padding = UDim.new(0.3, 0)}, 1.5, "Back", "Out")
	UpdatePage()

	do
		arrowRight = createObject ("TextButton", {
			BackgroundTransparency = 1,
			Size = UDim2.new(0, 30, 1, 0),
			Position = UDim2.new(1, 0, 0, 0),
			Font = Enum.Font.Arcade,
			TextScaled = true,
			TextColor3 = Color3.new(1, 1, 1),
			Text = ">", Name = "RightArrow",
			ZIndex = 3.0, Parent = itemFrame,

			createObject ("UIStroke", {
				Color = Color3.new(0, 0, 0), Thickness = 2
			}),

			MouseButton1Down = function()
				uiPageLayout:Next()
				UIBlip:Play()
				itemFrame:WaitForChild("RightArrow").Position = UDim2.new(1, -10, 0, 0)
				cursor.Rotation = 0
				TweenService:Create(itemFrame:WaitForChild("RightArrow"),
					TweenInfo.new(0.25,
						Enum.EasingStyle.Back,
						Enum.EasingDirection.Out),
					{Position = UDim2.new(1, -40, 0, 0)}):Play()
				TweenService:Create(cursor,
					TweenInfo.new(0.5,
						Enum.EasingStyle.Back,
						Enum.EasingDirection.Out),
					{Rotation = 90}):Play()
				UpdatePage()
			end
		})
		
		arrowLeft = createObject("TextButton", {
			BackgroundTransparency = 1,
			Size = UDim2.new(0, 30, 1, 0),
			Position = UDim2.new(0, -30, 0, 0),
			Font = Enum.Font.Arcade,
			TextScaled = true,
			TextColor3 = Color3.new(1, 1, 1),
			Text = "<", Name = "LeftArrow",
			ZIndex = 3.0, Parent = itemFrame,

			createObject("UIStroke", {
				Color = Color3.new(0, 0, 0), Thickness = 2
			}),

			MouseButton1Down = function()
				uiPageLayout:Previous()
				UIBlip:Play()
				itemFrame:WaitForChild("LeftArrow").Position = UDim2.new(0, 0, 0, 0)
				cursor.Rotation = 0
				TweenService:Create(itemFrame:WaitForChild("LeftArrow"), TweenInfo.new(0.25, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {Position = UDim2.new(0, 10, 0, 0)}):Play()
				TweenService:Create(cursor, TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {Rotation = -90}):Play()
				UpdatePage()
			end
		})
	end
	
	tween(arrowRight, {Position = UDim2.new(1, -40, 0, 0)}, 1.5, "Quart", "Out")
	tween(arrowLeft, {Position = UDim2.new(0, 10, 0, 0)}, 1.5, "Quart", "Out")
	task.wait(1)

	do
		topLabel = createObject("TextLabel", {
			BackgroundTransparency = 1,
			Size = UDim2.new(1, 0, 0, Utilities.IsMobile() and 30 or 40),
			Position = UDim2.new(Utilities.IsMobile() and 0 or -1, 0, Utilities.IsMobile() and -1 or 0, Utilities.IsMobile() and 0 or 40),
			TextXAlignment = Utilities.IsMobile() and Enum.TextXAlignment.Center or Enum.TextXAlignment.Left,
			Font = Enum.Font.Arcade,
			TextScaled = true,
			TextColor3 = Color3.new(1, 1, 1),
			Text = "Main Menu", Name = "topLabel",
			ZIndex = 2, Parent = gui,

			createObject("UIStroke", {
				Color = Color3.new(0, 0, 0), Thickness = 2
			})
		})
		versionLabel = createObject("TextLabel", {
			BackgroundTransparency = 1,
			Size = UDim2.new(1, 0, 0.05, 0),
			Position = UDim2.new(0, -20, 1, 0), Font = Enum.Font.Arcade,
			TextXAlignment = Utilities.IsMobile() and Enum.TextXAlignment.Center or Enum.TextXAlignment.Right,
			TextScaled = true, TextColor3 = Color3.new(1, 1, 1),
			Text = ReplicatedFirst:WaitForChild("GameVersion").Value,
			Name = "versionLabel", ZIndex = 2, Parent = gui,

			createObject("UIStroke", {
				Color = Color3.new(0, 0, 0), Thickness = 2
			})
		})
	end
	TweenService:Create(topLabel, TweenInfo.new(0.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Position = UDim2.new(0, 20, 0, Utilities.IsMobile() and 0 or 40)}):Play()
	TweenService:Create(versionLabel, TweenInfo.new(0.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Position = UDim2.new(0, -20, 0.94, 0)}):Play()
end

return mainMenu

(About the fact that there is Pokémon related code, this game is not going to be released unless approved, so pretty much, I don’t plan on releasing this game.)

1 Like

If the script editor shows errors, but does not run with errors, this is a bug. Have you tried restarting studio? If not, make a log file, then restart studio.

Restarting studio did not help, this is very confusing to me because the error lines state 'unknown global [etc]' while the code still runs. Any other ideas?

Put in a comment at the top of the script: --!nolint UnknownGlobal

It appears that hasn’t worked either, I’m open to any ideas but the script does work so I guess I can’t complain.

2 Likes

Using this the issue has been solved! Thank you so much!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.