Module require take long time load

Hello Roblox community,
I have a rather unusual problem that I’ve never encountered before.

I’ll show you a video so you can understand what I mean.

For those who didn’t understand the video, basically I have a script inside StarterCharacterScripts that runs several “ModuleScripts” in a folder. The problem with all this is that when the function is executed, it takes between 4-7 seconds to run. I tried to do prints and everything points to the error being in the “require.” I tried with corountimes, task

Can you send the error in the loader script?

there is not error, just taking long time to load modulescript

are there any task.wait()s in any of the scripts involved?

Nope, nothing any task.delay, nothing, just task.spawn

Can you please send the contents of the ButtonFunction module script? Feel free to remove any functions that aren’t Init, but include anything likely to run when you require it

The problem does not lead to anything within ButtonFunction since I use the :init() function in each module to start.

After the function, I put a print on the first line of code and it takes almost 5 seconds to load the entire require, which is strange.

1 Like


It very likely does occur because of something in the ButtonFunction module script, beyond the init.
As you are requiring it, all code that is in the main line has to be run, and I suspect that’s where the issue is.

The buttonFunction code is very large. Also, in each new function, I always use task.spawn, separating the loading processes. Do you think I should use coroutimes?

If you remove any functions that aren’t immediately run, is it short enough that you can reasonably send it?

(Also, instead of posting screenshots, can you please put the code as text within a codeblock in the post , by putting ``` (just copy and paste it) above and below the code)

(Also, the :Init() function is not the problem.)

Sure

local module = {}

--((Services))
local MarketplaceService = game:GetService("MarketplaceService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local HttpsService = game:GetService("HttpService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

--((Modules))
local WindowsEventsModule = require(replicatedStorage:FindFirstChild("Libs"):FindFirstChild("WindowsEventsRegister"))
local AbbreviateModule = require(replicatedStorage:FindFirstChild("Libs"):FindFirstChild("AbbreviateText"))
local StandsManager = require(replicatedStorage:FindFirstChild("Libs"):FindFirstChild("StandsManager"))
local ColorPicker = require(replicatedStorage:FindFirstChild("Packages"):FindFirstChild("ColorPicker"))
local FontsStyles = require(replicatedStorage:FindFirstChild("Libs"):FindFirstChild("FontsStyles"))
local Warp = require(replicatedStorage:FindFirstChild("Packages"):FindFirstChild("warp"))
local ConfigModule = require(script:FindFirstChild("ConfigModule"))
local trove = require(ReplicatedStorage.Packages.trove)

--((Variables))
local tweeninfo = TweenInfo.new(0.4, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local currentCamera = workspace.CurrentCamera
local debounce = false

local IslandGifting = nil
module.ActualStand = "default"
module.AngleStand = trove.new()

--((Remotes))
local claimGift = Warp.Client("claimGift")
local GiftRequest = Warp.Client("GiftRequest")
local UnclaimStand = Warp.Client("UnclaimStand")
local closeGifting = Warp.Client("closeGifting")
local sendInfoGifts = Warp.Client("sendInfoGifts")
local getInfoEdiText = Warp.Client("getInfoEdiText")
local updateTextTitle = Warp.Client("updateTextTitle")
local getUpdateConfig = Warp.Client("getUpdateConfig")
local putStandRequest = Warp.Client("putStandRequest")
local GiftLogsClientRequest = Warp.Client("GiftLogsRequest")
local getStandsInventory = Warp.Client("getStandsInventory")
local ChangeValueSettings = Warp.Client("ChangeValueSettings")
local ChangeTextEditStand = Warp.Client("ChangeTextEditStand")

local sendCommendsBindable: BindableEvent = replicatedStorage:FindFirstChild("Remotes"):FindFirstChild("sendComments")
local ClientRemotesGamepass: BindableEvent =
	replicatedStorage:FindFirstChild("Remotes"):FindFirstChild("ClientRemotesGamepass")

--((Objs))
local ButtonsDonations = script:FindFirstChild("ButtonsDonations")

--((Tablas))

function module:ShowPreviewStand(standName: string, preview: ViewportFrame)
	local StandsFolder = replicatedStorage:FindFirstChild("Stands")
	local FindStand = StandsFolder:FindFirstChild(standName)
	if FindStand == nil then
		return
	end

	local WorldModel = preview:FindFirstChild("WorldModel")

	for _, v in pairs(WorldModel:GetChildren()) do
		v:Destroy()
	end

	local clonedStand = FindStand:Clone() :: Model
	clonedStand.Parent = WorldModel
	clonedStand.Name = standName
	clonedStand:PivotTo(CFrame.new(Vector3.new(1, -6, -15)) * CFrame.Angles(0, math.rad(90), 0))
end

function module:_LoadGamepass(folder, pases)
	local scroll: ScrollingFrame = folder:FindFirstChild("ItemsPart"):FindFirstChild("Items"):FindFirstChild("Scroll")

	scroll.ScrollBarThickness = 4
	scroll.ScrollBarImageColor3 = Color3.fromRGB(190, 190, 190)

	local UIList = scroll:FindFirstChild("UIListLayout")
	UIList.VerticalAlignment = "Center"

	for _, v in pairs(pases) do
		local cloned = ButtonsDonations:Clone()
		cloned:SetAttribute("ID", v["id"])
		cloned:SetAttribute("PRICE", v["price"])
		cloned.Text = "$" .. AbbreviateModule:abbreviateNums(v["price"]) or "$" .. v["price"]
		cloned.Parent = scroll

		local owned = MarketplaceService:UserOwnsGamePassAsync(Players.LocalPlayer.UserId, tonumber(v["id"]))
		if owned then
			cloned.BackgroundColor3 = Color3.fromRGB(67, 129, 63)
			cloned.TextColor3 = Color3.fromRGB(158, 158, 158)
		end
	end
end

function module:hexToColor3(hex)
	hex = hex:gsub("#", "") -- elimina el símbolo #
	local r = tonumber(hex:sub(1, 2), 16)
	local g = tonumber(hex:sub(3, 4), 16)
	local b = tonumber(hex:sub(5, 6), 16)
	return Color3.fromRGB(r, g, b)
end

function module:Init()
	print("TESTING")

	local PlayerGui = Players.LocalPlayer.PlayerGui

	local Menu: Folder = PlayerGui:FindFirstChild("Menu")
	local Buttons: Folder = PlayerGui:FindFirstChild("Buttons")

	local ScreenMenu = Menu:FindFirstChild("Screen")
	local ScreenButtons = Buttons:FindFirstChild("Screen")

	local buttonFunciones = {
		["Gift"] = function()
			local fondo: ImageLabel = ScreenMenu:FindFirstChild("Gift"):FindFirstChild("Fondo")

			if fondo.Visible then
				WindowsEventsModule:CloseMenu(fondo)
			else
				WindowsEventsModule:OpenMenu(fondo)
			end
		end,

		["Dances"] = function() end,

		["Store"] = function() end,

		["Config"] = function()
			local fondo = ScreenMenu:FindFirstChild("Configuration"):FindFirstChild("Fondo") :: ImageLabel

			if fondo.Visible then
				WindowsEventsModule:CloseMenu(fondo)
			else
				WindowsEventsModule:OpenMenu(fondo)
			end
		end,

		["Code"] = function() end,

		["EditStand"] = function()
			local EditFolder = ScreenMenu:FindFirstChild("Edit")
			local Fondo = EditFolder:FindFirstChild("Fondo")

			if Fondo.Visible then
				WindowsEventsModule:CloseMenu(Fondo)
			else
				WindowsEventsModule:OpenMenu(Fondo)
			end
		end,
	}
	-- detect stand
	task.spawn(function()
		local LeftFrame = ScreenButtons:FindFirstChild("Left")
		local EditStandButton = LeftFrame:FindFirstChild("EditStand")

		Players.LocalPlayer:GetAttributeChangedSignal("HAVESTAND"):Connect(function()
			if Players.LocalPlayer:GetAttribute("HAVESTAND") then
				EditStandButton.Visible = true
			else
				EditStandButton.Visible = false
			end
		end)
	end)

	task.spawn(function()
		-- button config
		local Buttons_F = ScreenButtons:FindFirstChild("Left") :: Frame

		for _, v in pairs(Buttons_F:GetChildren()) do
			if v:IsA("ImageButton") then
				local InfoButton = {}
				InfoButton[v] = {
					["LogoSize"] = v.Logo.Size,
					["LogoPos"] = v.Logo.Position,
					["Rotation"] = v.Logo.Rotation,
					["SizeButton"] = v.Size,
				}

				v.MouseLeave:Connect(function()
					local x = TweenService:Create(v.Logo, tweeninfo, {
						Size = InfoButton[v]["LogoSize"],
						Position = InfoButton[v]["LogoPos"],
						Rotation = InfoButton[v]["Rotation"],
					})
					local x_1 = TweenService:Create(v, tweeninfo, {
						Size = InfoButton[v]["SizeButton"],
					})
					x:Play()
					x_1:Play()
				end)

				v.MouseEnter:Connect(function()
					local x_1 = TweenService:Create(v, tweeninfo, {
						Size = v.Size + UDim2.fromScale(0.1, 0.1),
					})
					local x = TweenService:Create(v.Logo, tweeninfo, {
						Size = v.Logo.Size + UDim2.fromScale(0.04, 0.04),
						Position = v.Logo.Position - UDim2.fromScale(0, 0.05),
						Rotation = v.Logo.Rotation + 30,
					})
					x:Play()
					x_1:Play()
				end)

				v.MouseButton1Click:Connect(function()
					if debounce then
						return
					end
					debounce = true
					if buttonFunciones[v.Name] == nil then
						debounce = false
						return
					end
					buttonFunciones[v.Name]()
					debounce = false
				end)
			end
		end
	end)

	-- update config
	task.spawn(function()
		local Settings = ScreenMenu:FindFirstChild("Configuration") :: Frame
		local F_Settings = Settings:FindFirstChild("Fondo") :: ImageLabel
		local Scroll = F_Settings:FindFirstChild("Scroll") :: ScrollingFrame

		local F_EffectDonations = Settings:FindFirstChild("EffectsDonations") :: ImageLabel
		local Scroll_EffectDonations = F_EffectDonations:FindFirstChild("Scroll") :: ScrollingFrame

		local x = getUpdateConfig:Invoke(5)
		if x then
			-- config gameplay
			for nombre, valor in pairs(x) do
				if nombre == "Donations" then
					continue
				end

				local findTemplate = Scroll:FindFirstChild(nombre)
				if findTemplate then
					local ButtonFind = findTemplate:FindFirstChild("Button")
					if ButtonFind then
						local Title = ButtonFind:FindFirstChild("title") :: TextLabel
						if Title == nil then
							continue
						end

						if valor then
							Title.Text = "ON"
							findTemplate:SetAttribute("ENABLED", false)
						else
							Title.Text = "OFF"
							findTemplate:SetAttribute("ENABLED", true)
						end
					end
				end
			end

			for nombre, valor in x["Donations"] do
				local findTemplate = Scroll_EffectDonations:FindFirstChild(nombre)
				if findTemplate then
					local ButtonFind = findTemplate:FindFirstChild("Button")
					if ButtonFind then
						local Title = ButtonFind:FindFirstChild("title") :: TextLabel
						if Title == nil then
							continue
						end

						if valor then
							Title.Text = "ON"
							findTemplate:SetAttribute("ENABLED", true)
						else
							findTemplate:SetAttribute("ENABLED", false)
							Title.Text = "OFF"
						end
					end
				end
			end
		end
	end)

	task.spawn(function()
		local Templates = PlayerGui:FindFirstChild("Template")
		local Screen = Templates:FindFirstChild("Screen")

		local CancelGifting: ImageButton = Screen:FindFirstChild("CancelGifting")

		CancelGifting.MouseButton1Click:Connect(function()
			if Players.LocalPlayer:GetAttribute("GIFTING") then
				closeGifting:Fire(false)
				CancelGifting.Visible = false

				if IslandGifting then
					currentCamera.CameraType = Enum.CameraType.Custom

					IslandGifting:Destroy()
					IslandGifting = nil
				end
			end
		end)
	end)

	-- config config
	task.spawn(function()
		local ConfigurationFolder = ScreenMenu:FindFirstChild("Configuration")
		local Fondo = ConfigurationFolder:FindFirstChild("Fondo") :: ImageLabel
		local Scroll = Fondo:FindFirstChild("Scroll") :: ScrollingFrame
		local CloseButton = Fondo:FindFirstChild("Close") :: ImageButton
		local EffectDonations_F = ConfigurationFolder:FindFirstChild("EffectsDonations")

		CloseButton.MouseButton1Click:Connect(function()
			WindowsEventsModule:CloseMenu(Fondo)
		end)

		task.spawn(function()
			for _, v in EffectDonations_F.Scroll:GetChildren() do
				local ButtonActivated = v:FindFirstChild("Button") :: ImageButton

				if ButtonActivated then
					local title = ButtonActivated:FindFirstChild("title")

					ButtonActivated.MouseButton1Click:Connect(function()
						if not v:GetAttribute("ENABLED") then
							v:SetAttribute("ENABLED", true)
							title.Text = "OFF"

							if v:GetAttribute("LOCAL") then
								ConfigModule[v.Name](v:GetAttribute("ENABLED"))
							end

							ChangeValueSettings:Fire(false, v.Name, false, true)
						else
							v:SetAttribute("ENABLED", false)
							title.Text = "ON"

							if v:GetAttribute("LOCAL") then
								ConfigModule[v.Name](v:GetAttribute("ENABLED"))
							end

							ChangeValueSettings:Fire(false, v.Name, true, true)
						end
					end)
				end
			end
		end)

		task.spawn(function()
			for _, v in Scroll:GetChildren() do
				if v.Name == "zzzzzz" then
					continue
				end

				local ButtonActivated = v:FindFirstChild("Button") :: ImageButton

				if ButtonActivated then
					local title = ButtonActivated:FindFirstChild("title")

					ButtonActivated.MouseButton1Click:Connect(function()
						if v.Name == "Donations" then
							if EffectDonations_F.Visible then
								local openMenu = TweenService:Create(EffectDonations_F, tweeninfo, {
									Position = UDim2.fromScale(0.758, 1.534),
								})
								openMenu:Play()
								openMenu.Completed:Connect(function()
									EffectDonations_F.Visible = false
								end)
							else
								EffectDonations_F.Visible = true
								local openMenu = TweenService:Create(EffectDonations_F, tweeninfo, {
									Position = UDim2.fromScale(0.758, 0.534),
								})
								openMenu:Play()
							end
						else
							if not v:GetAttribute("ENABLED") then
								v:SetAttribute("ENABLED", true)
								title.Text = "OFF"

								if v:GetAttribute("LOCAL") then
									ConfigModule[v.Name](v:GetAttribute("ENABLED"))
								end

								ChangeValueSettings:Fire(false, v.Name, false, nil)
							else
								v:SetAttribute("ENABLED", false)
								title.Text = "ON"

								if v:GetAttribute("LOCAL") then
									ConfigModule[v.Name](v:GetAttribute("ENABLED"))
								end

								ChangeValueSettings:Fire(false, v.Name, true, nil)
							end
						end
					end)
				end
			end
		end)
	end)

	-- inventoryButton
	task.spawn(function()
		local Gift_F = ScreenMenu:FindFirstChild("Gift")
		local Fondo_Gift = Gift_F:FindFirstChild("Fondo")
		local InventoryButton = Fondo_Gift:FindFirstChild("Inventory")

		local BackpackStand = ScreenMenu:FindFirstChild("GiftInventorys")
		local FondoBackpack = BackpackStand:FindFirstChild("Fondo")

		local BackButton = FondoBackpack:FindFirstChild("Back")

		local SendButton = Fondo_Gift:FindFirstChild("Send")
		local CloseButton = Fondo_Gift:FindFirstChild("Close")

		local SizeCloseButton = CloseButton.Size
		local SizeSendButton = SendButton.Size
		local SizeInventoryButton = InventoryButton.Size

		InventoryButton.MouseEnter:Connect(function()
			local x = TweenService:Create(InventoryButton, tweeninfo, {
				Size = InventoryButton.Size + UDim2.fromScale(0.03, 0.03),
			})
			x:Play()
		end)

		InventoryButton.MouseLeave:Connect(function()
			local x = TweenService:Create(InventoryButton, tweeninfo, {
				Size = SizeInventoryButton,
			})
			x:Play()
		end)

		SendButton.MouseEnter:Connect(function()
			local x = TweenService:Create(SendButton, tweeninfo, {
				Size = SendButton.Size + UDim2.fromScale(0.03, 0.03),
			})
			x:Play()
		end)

		SendButton.MouseLeave:Connect(function()
			local x = TweenService:Create(SendButton, tweeninfo, {
				Size = SizeSendButton,
			})
			x:Play()
		end)

		CloseButton.MouseEnter:Connect(function()
			local x = TweenService:Create(CloseButton, tweeninfo, {
				Size = CloseButton.Size + UDim2.fromScale(0.03, 0.03),
			})
			x:Play()
		end)

		CloseButton.MouseLeave:Connect(function()
			local x = TweenService:Create(CloseButton, tweeninfo, {
				Size = SizeCloseButton,
			})
			x:Play()
		end)

		CloseButton.MouseButton1Click:Connect(function()
			WindowsEventsModule:CloseMenu(Fondo_Gift)
		end)

		BackButton.MouseButton1Down:Connect(function()
			WindowsEventsModule:CloseMenu(FondoBackpack)
			WindowsEventsModule:OpenMenu(Fondo_Gift)
		end)

		InventoryButton.MouseButton1Down:Connect(function()
			if FondoBackpack.Visible then
				WindowsEventsModule:CloseMenu(FondoBackpack)
			else
				WindowsEventsModule:CloseMenu(Fondo_Gift)
				WindowsEventsModule:OpenMenu(FondoBackpack)
			end
		end)
	end)

	task.spawn(function()
		local GiftInventorys = ScreenMenu:FindFirstChild("GiftInventorys")
		local Fondo_Gift = GiftInventorys:FindFirstChild("Fondo")
		local Scroll = Fondo_Gift:FindFirstChild("Scroll")

		local x = GiftLogsClientRequest:Invoke(10)
		if x then
			for _, v in pairs(Scroll:GetChildren()) do
				if v:IsA("ImageButton") then
					v:Destroy()
				end
			end

			for hash, v in pairs(x) do
				local DeEncode = HttpsService:JSONDecode(v)
				local TemplateGift: ImageLabel = script:FindFirstChild("TemplateGift"):Clone()

				local getName = Players:GetNameFromUserIdAsync(DeEncode["PlayerToSend"])

				local Avatar = TemplateGift:FindFirstChild("Avatar")
				local Message = TemplateGift:FindFirstChild("Message")
				local Username = TemplateGift:FindFirstChild("Username")
				local ClaimButton = TemplateGift:FindFirstChild("Claim")

				Avatar:FindFirstChild("ImageLabel").Image = Players:GetUserThumbnailAsync(
					DeEncode["PlayerToSend"],
					Enum.ThumbnailType.HeadShot,
					Enum.ThumbnailSize.Size150x150
				)
				TemplateGift.Name = hash
				Username.Text = getName
				Message.TextLabel.Text = DeEncode["Message"]
				ClaimButton.TextLabel.Text = "\u{E002}" .. DeEncode["Amount"] .. " Claim!"

				TemplateGift.Parent = Scroll

				ClaimButton.MouseButton1Click:Connect(function()
					local status = claimGift:Invoke(10, hash)
					if status then
						TemplateGift:Destroy()
						sendCommendsBindable:Fire("sucess", "You claimed the gift.")
					end
				end)
			end
		end

		sendInfoGifts:Connect(function(tableInfo)
			for _, v in pairs(Scroll:GetChildren()) do
				if v:IsA("ImageButton") then
					v:Destroy()
				end
			end

			for hash, v in pairs(tableInfo) do
				local DeEncode = HttpsService:JSONDecode(v)

				local TemplateGift: ImageLabel = script:FindFirstChild("TemplateGift"):Clone()
				local getName = Players:GetNameFromUserIdAsync(DeEncode["PlayerToSend"])

				local Avatar = TemplateGift:FindFirstChild("Avatar")
				local Message = TemplateGift:FindFirstChild("Message")
				local Username = TemplateGift:FindFirstChild("Username")
				local ClaimButton = TemplateGift:FindFirstChild("Claim")

				Avatar:FindFirstChild("ImageLabel").Image = Players:GetUserThumbnailAsync(
					DeEncode["PlayerToSend"],
					Enum.ThumbnailType.HeadShot,
					Enum.ThumbnailSize.Size150x150
				)
				TemplateGift.Name = hash
				Username.Text = getName
				Message.TextLabel.Text = DeEncode["Message"]
				ClaimButton.TextLabel.Text = "\u{E002}" .. DeEncode["Amount"] .. " Claim!"

				TemplateGift.Parent = Scroll

				ClaimButton.MouseButton1Click:Connect(function()
					local status = claimGift:Invoke(10, hash)
					if status then
						TemplateGift:Destroy()
						sendCommendsBindable:Fire("sucess", "You claimed the gift.")
					end
				end)
			end
		end)
	end)

	-- Edit Stand Inventory
	task.spawn(function()
		local EditFolder = ScreenMenu:FindFirstChild("Edit")
		local Fondo = EditFolder:FindFirstChild("Fondo")

		local EditStand = ScreenMenu:FindFirstChild("EditStand")
		local FondoStand = EditStand:FindFirstChild("Fondo")

		local CloseButton = Fondo:FindFirstChild("Close") :: ImageButton
		local EditStandButton = Fondo:FindFirstChild("EditStand") :: ImageButton
		local InventoryButton = Fondo:FindFirstChild("Inventory") :: ImageButton
		local EditText = Fondo:FindFirstChild("EditText") :: ImageButton

		local UnclaimButton = Fondo:FindFirstChild("UnClaim") :: ImageButton

		UnclaimButton.MouseButton1Click:Connect(function()
			local x = UnclaimStand:Invoke(10)

			if x then
				WindowsEventsModule:CloseMenu(Fondo)
				sendCommendsBindable:Fire("sucess", "Stand removed correctly.")
			else
				sendCommendsBindable:Fire("error", "Error happend, try again later.")
			end
		end)

		CloseButton.MouseButton1Click:Connect(function()
			WindowsEventsModule:CloseMenu(Fondo)
		end)

		EditStandButton.MouseButton1Click:Connect(function()
			WindowsEventsModule:CloseMenu(Fondo)
			WindowsEventsModule:OpenMenu(FondoStand)
		end)

		InventoryButton.MouseButton1Click:Connect(function()
			local StandInventory = ScreenMenu:FindFirstChild("StandInventory")
			local FondoInventory = StandInventory:FindFirstChild("Fondo")

			WindowsEventsModule:CloseMenu(Fondo)
			WindowsEventsModule:OpenMenu(FondoInventory)
		end)

		EditText.MouseButton1Click:Connect(function()
			local EditTextFolder = ScreenMenu:FindFirstChild("EditText")
			local FondoEditText = EditTextFolder:FindFirstChild("Fondo")

			WindowsEventsModule:CloseMenu(Fondo)
			WindowsEventsModule:OpenMenu(FondoEditText)
		end)

		coroutine.wrap(function()
			local TempLogo = {}

			TempLogo = {
				["Size"] = UnclaimButton.Size,
				["Pos"] = UnclaimButton.Position,
			}

			local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)

			UnclaimButton.MouseEnter:Connect(function()
				TweenService:Create(UnclaimButton, tweenInfo, {
					--Position = EditText.Flecha.Logo.Position + UDim2.new(0.3, 0, 0, 0),
					Size = UnclaimButton.Size + UDim2.fromScale(0.02, 0.02),
				}):Play()
			end)

			UnclaimButton.MouseLeave:Connect(function()
				TweenService:Create(UnclaimButton, tweenInfo, {
					Position = TempLogo["Pos"],
					Size = TempLogo["Size"],
				}):Play()
			end)
		end)()

		coroutine.wrap(function()
			local TempLogo = {}

			TempLogo = {
				["Size"] = CloseButton.Size,
				["Pos"] = CloseButton.Position,
			}

			local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)

			CloseButton.MouseEnter:Connect(function()
				TweenService:Create(CloseButton, tweenInfo, {
					--Position = EditText.Flecha.Logo.Position + UDim2.new(0.3, 0, 0, 0),
					Size = CloseButton.Size + UDim2.fromScale(0.02, 0.02),
				}):Play()
			end)

			CloseButton.MouseLeave:Connect(function()
				TweenService:Create(CloseButton, tweenInfo, {
					Position = TempLogo["Pos"],
					Size = TempLogo["Size"],
				}):Play()
			end)
		end)()

		coroutine.wrap(function()
			local TempLogo = {}

			TempLogo["Logo"] = {
				["Size"] = EditStandButton.Logo.Size,
				["Pos"] = EditStandButton.Logo.Position,
			}

			TempLogo["Flecha"] = {
				["Size"] = EditStandButton.Flecha.Logo.Size,
				["Pos"] = EditStandButton.Flecha.Logo.Position,
			}

			local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)

			EditStandButton.MouseEnter:Connect(function()
				TweenService:Create(EditStandButton.Logo, tweenInfo, {
					Position = EditStandButton.Logo.Position - UDim2.fromScale(0, 0.2),
					Size = EditStandButton.Logo.Size + UDim2.fromScale(0.3, 0.2),
				}):Play()

				TweenService:Create(EditStandButton.Flecha.Logo, tweenInfo, {
					Position = EditStandButton.Flecha.Logo.Position + UDim2.fromScale(0.3, 0),
					--Size = EditStandButton.Logo.Size + UDim2.new(0.2, 0, 0.2, 0),
				}):Play()
			end)

			EditStandButton.MouseLeave:Connect(function()
				TweenService:Create(EditStandButton.Logo, tweenInfo, {
					Position = TempLogo["Logo"]["Pos"],
					Size = TempLogo["Logo"]["Size"],
				}):Play()

				TweenService:Create(EditStandButton.Flecha.Logo, tweenInfo, {
					Position = TempLogo["Flecha"]["Pos"],
					Size = TempLogo["Flecha"]["Size"],
				}):Play()
			end)
		end)()

		coroutine.wrap(function()
			local TempLogo = {}

			TempLogo["Logo"] = {
				["Size"] = InventoryButton.Logo.Size,
				["Pos"] = InventoryButton.Logo.Position,
			}

			TempLogo["Flecha"] = {
				["Size"] = InventoryButton.Flecha.Logo.Size,
				["Pos"] = InventoryButton.Flecha.Logo.Position,
			}

			local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)

			InventoryButton.MouseEnter:Connect(function()
				TweenService:Create(InventoryButton.Logo, tweenInfo, {
					Position = InventoryButton.Logo.Position - UDim2.fromScale(0, 0.2),
					Size = InventoryButton.Logo.Size + UDim2.fromScale(0.3, 0.2),
				}):Play()

				TweenService:Create(InventoryButton.Flecha.Logo, tweenInfo, {
					Position = InventoryButton.Flecha.Logo.Position + UDim2.fromScale(0.3, 0),
					--Size = EditStandButton.Logo.Size + UDim2.new(0.2, 0, 0.2, 0),
				}):Play()
			end)

			InventoryButton.MouseLeave:Connect(function()
				TweenService:Create(InventoryButton.Logo, tweenInfo, {
					Position = TempLogo["Logo"]["Pos"],
					Size = TempLogo["Logo"]["Size"],
				}):Play()

				TweenService:Create(InventoryButton.Flecha.Logo, tweenInfo, {
					Position = TempLogo["Flecha"]["Pos"],
					Size = TempLogo["Flecha"]["Size"],
				}):Play()
			end)
		end)()

		coroutine.wrap(function()
			local TempLogo = {}

			TempLogo["Logo"] = {
				["Size"] = EditText.Logo.Size,
				["Pos"] = EditText.Logo.Position,
			}

			TempLogo["Flecha"] = {
				["Size"] = EditText.Flecha.Logo.Size,
				["Pos"] = EditText.Flecha.Logo.Position,
			}

			local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)

			EditText.MouseEnter:Connect(function()
				TweenService:Create(EditText.Logo, tweenInfo, {
					Position = EditText.Logo.Position - UDim2.fromScale(0, 0.2),
					Size = EditText.Logo.Size + UDim2.fromScale(0.3, 0.2),
				}):Play()

				TweenService:Create(EditText.Flecha.Logo, tweenInfo, {
					Position = EditText.Flecha.Logo.Position + UDim2.fromScale(0.3, 0),
					--Size = EditStandButton.Logo.Size + UDim2.new(0.2, 0, 0.2, 0),
				}):Play()
			end)

			EditText.MouseLeave:Connect(function()
				TweenService:Create(EditText.Logo, tweenInfo, {
					Position = TempLogo["Logo"]["Pos"],
					Size = TempLogo["Logo"]["Size"],
				}):Play()

				TweenService:Create(EditText.Flecha.Logo, tweenInfo, {
					Position = TempLogo["Flecha"]["Pos"],
					Size = TempLogo["Flecha"]["Size"],
				}):Play()
			end)
		end)()
	end)

	-- gift menu
	task.spawn(function()
		local Gift_F = ScreenMenu:FindFirstChild("Gift")
		local Fondo_Gift = Gift_F:FindFirstChild("Fondo")
		local Send_Gift = Fondo_Gift:FindFirstChild("Send")
		local UsernameBox = Fondo_Gift:FindFirstChild("Username"):FindFirstChild("TextBox")
		local MessageBox = Fondo_Gift:FindFirstChild("Message"):FindFirstChild("TextBox")

		Send_Gift.MouseButton1Click:Connect(function()
			if #UsernameBox.Text <= 0 then
				sendCommendsBindable:Fire("error", "You need put a username there.")
				return
			end

			local getFov = currentCamera.FieldOfView

			local a = TweenService:Create(currentCamera, tweeninfo, { FieldOfView = 50 })
			a:Play()

			local x = GiftRequest:Invoke(10, UsernameBox.Text, MessageBox.Text)

			if x == "self_donation" then
				sendCommendsBindable:Fire("error", "You can't donate to yourself.")
				return
			end

			if x then
				local getInfoProfile
				if x[1] == nil then
					getInfoProfile = {
						raised = 0,
						donated = 0,
						points = 0,
						text_stand = "No text",
						actualStand = "default",
					}
				else
					getInfoProfile = x[1]
				end

				local getGamepassInfo = x[2]

				local UserId = Players:GetUserIdFromNameAsync(UsernameBox.Text)
				local PlayerName = Players:GetNameFromUserIdAsync(UserId)

				local stand = replicatedStorage
					:FindFirstChild("Stands")
					:FindFirstChild(getInfoProfile.actualStand or "default")
					:Clone()
				if stand == nil then
					return
				end

				buttonFunciones["Gift"]()

				-- cloned island
				local islandName = HttpsService:GenerateGUID()
				local island_Folder = replicatedStorage:FindFirstChild("GiftOffline"):Clone()
				island_Folder.Parent = workspace
				island_Folder.Name = islandName

				IslandGifting = island_Folder

				currentCamera.CameraType = Enum.CameraType.Scriptable

				currentCamera.CFrame = island_Folder.Camera.CFrame

				local b = TweenService:Create(currentCamera, tweeninfo, { FieldOfView = getFov })
				b:Play()

				--place stand
				stand.Parent = island_Folder
				stand:PivotTo(island_Folder.BasePositionPart.CFrame)

				stand:FindFirstChild("Title"):FindFirstChild("Sur"):FindFirstChild("TextLabel").Text =
					getInfoProfile.text_stand
				stand:FindFirstChild("SubTitle"):FindFirstChild("Sur"):FindFirstChild("Raised").Text = "Raised: "
					.. getInfoProfile.raised
				stand:FindFirstChild("SubTitle"):FindFirstChild("Sur"):FindFirstChild("Username").Text = "@"
					.. PlayerName

				sendCommendsBindable:Fire("sucess", "Gifting sucess...")

				-- activandose el boton
				local Template = PlayerGui.Template.Screen
				local CancelGifting = Template:FindFirstChild("CancelGifting")

				CancelGifting.Visible = true

				-- loading screen
				module:_LoadGamepass(stand, getGamepassInfo)
				ClientRemotesGamepass:Fire(
					stand:FindFirstChild("ItemsPart"):FindFirstChild("Items"):FindFirstChild("Scroll")
				)
			else
				sendCommendsBindable:Fire("error", "Error happend, try again later.")

				local b = TweenService:Create(currentCamera, tweeninfo, { FieldOfView = getFov })
				b:Play()
			end
		end)
	end)

	-- edit menu
	task.spawn(function()
		local EditStand = ScreenMenu:FindFirstChild("EditStand"):FindFirstChild("Fondo")
		local EditFondo = ScreenMenu:FindFirstChild("Edit"):FindFirstChild("Fondo")

		local Back = EditStand:FindFirstChild("Back")
		local Send = EditStand:FindFirstChild("Save")

		local FondoFrame = EditStand:FindFirstChild("Fondo")
		local TextoTitle = FondoFrame:FindFirstChild("TextBox")

		Send.MouseButton1Click:Connect(function()
			if #TextoTitle.Text <= 0 then
				sendCommendsBindable:Fire("error", "You need put a text.")
				return
			end
			updateTextTitle:Fire(false, TextoTitle.Text)
			sendCommendsBindable:Fire("sucess", "Title changed correctly.")
			WindowsEventsModule:CloseMenu(EditStand)
		end)

		Back.MouseButton1Click:Connect(function()
			WindowsEventsModule:CloseMenu(EditStand)
			WindowsEventsModule:OpenMenu(EditFondo)
		end)

		--[[
		Unclaim.MouseButton1Click:Connect(function()
			local x = UnclaimStand:Invoke(10)

			if x then
				closeMenu(EditStand)

				sendCommendsBindable:Fire("sucess", "Stand removed correctly.")
			else
				sendCommendsBindable:Fire("error", "Error happend, try again later.")
			end
		end)
		]]
	end)

	-- inventoryStand fondo
	task.spawn(function()
		local Edit = ScreenMenu:FindFirstChild("Edit")
		local FondoEdit = Edit:FindFirstChild("Fondo")

		local StandInventory = ScreenMenu:FindFirstChild("StandInventory")
		local FondoInventory = StandInventory:FindFirstChild("Fondo")

		local StandPreview = FondoInventory:FindFirstChild("StandPreview") :: ViewportFrame
		local BackButton = FondoInventory:FindFirstChild("Back") :: ImageButton
		local TitleStand = FondoInventory:FindFirstChild("TitleStand") :: TextLabel
		local OwnerStand = FondoInventory:FindFirstChild("OwnerStand") :: TextLabel
		local Rarity = FondoInventory:FindFirstChild("Rarity") :: ImageLabel
		local Mode = FondoInventory:FindFirstChild("Mode") :: ImageLabel
		local Seleccion = FondoInventory:FindFirstChild("Seleccion") :: ImageLabel
		local Scroll = Seleccion:FindFirstChild("Scroll") :: ScrollingFrame

		local InfoStand = StandsManager[self.ActualStand]
		TitleStand.Text = InfoStand["NAME"]
		OwnerStand.Text = InfoStand["OWNER"]

		if InfoStand["MODE"] == "CODE" then
			Mode.Image = "rbxassetid://" .. 130820800715953
		end
		if InfoStand["MODE"] == "COINS" then
			Mode.Image = "rbxassetid://" .. 112827378586111
		end

		if InfoStand["RARITY"] == "Common" then
			Rarity.Image = "rbxassetid://" .. 129882613131254
		end
		if InfoStand["RARITY"] == "Rare" then
			Rarity.Image = "rbxassetid://" .. 106734248641105
		end
		if InfoStand["RARITY"] == "Legendary" then
			Rarity.Image = "rbxassetid://" .. 81148090302247
		end

		task.spawn(function()
			self:ShowPreviewStand(self.ActualStand, StandPreview)

			local WorldModel = StandPreview:FindFirstChild("WorldModel")
			self.AngleStand:Connect(RunService.Heartbeat, function()
				local currentCFrame = WorldModel:GetPivot()
				local rotation = CFrame.Angles(0, math.rad(1), 0)
				WorldModel:PivotTo(currentCFrame * rotation)
			end)
		end)

		BackButton.MouseButton1Click:Connect(function()
			WindowsEventsModule:CloseMenu(FondoInventory)
			WindowsEventsModule:OpenMenu(FondoEdit)
		end)

		task.spawn(function()
			local x = getStandsInventory:Invoke(10)
			if x then
				for _, v in pairs(x) do
					local findingStand = replicatedStorage:FindFirstChild("Stands"):FindFirstChild(v)
					if findingStand == nil then
						continue
					end

					local clonedStand = script:FindFirstChild("TemplateBooth"):Clone()
					clonedStand.Parent = Scroll
					clonedStand.Logo.Image = findingStand:GetAttribute("IMG")
					clonedStand.Name = v

					clonedStand.MouseButton1Click:Connect(function()
						if self.ActualStand == clonedStand.Name then
							sendCommendsBindable:Fire("error", "You are ready have this stand place it.")
							return
						end

						putStandRequest:Fire(false, v)
					end)
				end
			end
		end)
	end)

	-- edit text
	task.spawn(function()
		local newColorPicker = ColorPicker.new()
		local preColorSelected = false
		local _PositionStroke = 0.1

		local EditText = ScreenMenu:FindFirstChild("EditText")
		local FondoEditText = EditText:FindFirstChild("Fondo")

		local BackButton = FondoEditText:FindFirstChild("Back") :: ImageButton
		local TextColor = FondoEditText:FindFirstChild("TextColor")
		local ColorSelected = TextColor:FindFirstChild("ColorSelected") :: TextButton

		-- TextStroke
		local TextStroke = FondoEditText:FindFirstChild("TextStroke")
		local Linea = TextStroke:FindFirstChild("Linea")
		local ColorSelectedStroke = Linea:FindFirstChild("ColorSelected") :: TextButton

		-- Font Style
		local ChangeFont = FondoEditText:FindFirstChild("ChangeFont"):FindFirstChild("Fondo")
		local Derecha_Bottom = ChangeFont:FindFirstChild("Derecha") :: ImageButton
		local Izquierda_Bottom = ChangeFont:FindFirstChild("Izquierda") :: ImageButton
		local ActualFont = ChangeFont:FindFirstChild("Actual") :: TextLabel
		local getNumber = 2

		task.spawn(function()
			Derecha_Bottom.MouseButton1Click:Connect(function()
				getNumber = FontsStyles:GetNumber(ActualFont.Text)
				getNumber -= 1
				if FontsStyles.ArrayFonts[getNumber] == nil then
					getNumber = 38
				end
				ActualFont.Text = FontsStyles.ArrayFonts[getNumber]
				ActualFont.Font = FontsStyles:GetFont(FontsStyles.ArrayFonts[getNumber])
				ChangeTextEditStand:Fire(false, "TextFont", FontsStyles.ArrayFonts[getNumber])
			end)

			Izquierda_Bottom.MouseButton1Click:Connect(function()
				getNumber = FontsStyles:GetNumber(ActualFont.Text)
				getNumber += 1
				if FontsStyles.ArrayFonts[getNumber] == nil then
					getNumber = 1
				end
				ActualFont.Text = FontsStyles.ArrayFonts[getNumber]
				ActualFont.Font = FontsStyles:GetFont(FontsStyles.ArrayFonts[getNumber])
				ChangeTextEditStand:Fire(false, "TextFont", FontsStyles.ArrayFonts[getNumber])
			end)
		end)

		-- get info
		task.spawn(function()
			local getInfo = getInfoEdiText:Invoke(5)
			if getInfo then
				local getInfoColor = self:hexToColor3(getInfo.TextColor)
				ColorSelected.BackgroundColor3 = getInfoColor

				-- ui stroke
				_PositionStroke = getInfo.Stroke
				ColorSelectedStroke.Position = UDim2.fromScale(_PositionStroke, 0.5)

				ActualFont.Text = getInfo.Font
				local getFont = FontsStyles:GetFont(getInfo.Font)
				if getFont then
					ActualFont.Font = getFont
				end
			end
		end)

		task.spawn(function()
			local UIDragDetector = ColorSelectedStroke:FindFirstChild("UIDragDetector") :: UIDragDetector

			UIDragDetector.DragContinue:Connect(function()
				_PositionStroke = ColorSelectedStroke.Position.X.Scale
			end)

			UIDragDetector.DragEnd:Connect(function()
				ChangeTextEditStand:Fire(false, "TextStroke", _PositionStroke)
			end)
		end)

		ColorSelected.MouseButton1Click:Connect(function()
			newColorPicker:Start()
		end)

		newColorPicker.Closed:Connect(function()
			ChangeTextEditStand:Fire(false, "TextColor", preColorSelected)
		end)

		newColorPicker.Changed:Connect(function(color)
			TweenService:Create(ColorSelected, TweenInfo.new(0.1), {
				BackgroundColor3 = color,
			}):Play()
			preColorSelected = color
		end)

		BackButton.MouseButton1Click:Connect(function()
			local EditFolder = ScreenMenu:FindFirstChild("Edit")
			local Fondo = EditFolder:FindFirstChild("Fondo")

			WindowsEventsModule:CloseMenu(FondoEditText)
			WindowsEventsModule:OpenMenu(Fondo)
		end)
	end)

	--[[
	
	
	-- get stands
	task.spawn(function()
		local EditStand : Frame = ScreenMenu:FindFirstChild("EditStand"):FindFirstChild("Fondo")
		local BackpackStand : Frame = ScreenMenu:FindFirstChild("BackpackStand")
		local FondoBackpack : ImageLabel = BackpackStand:FindFirstChild("Fondo")
		local ScrollBackpack : ScrollingFrame = FondoBackpack:FindFirstChild("Scroll")
		local CloseBack : ImageButton = FondoBackpack:FindFirstChild("Close")
		
		CloseBack.MouseButton1Click:Connect(function()
			closeMenu(FondoBackpack)
			openMenu(EditStand)
		end)
		
		local x = getStandsInventory:Invoke(10)
		
		if x then
			
			for e,v in pairs(x) do
				
				local findingStand = replicatedStorage:FindFirstChild("Stands"):FindFirstChild(v)
				if findingStand == nil then continue end
				
				local clonedStand = script:FindFirstChild("BoothCloned"):Clone()
				clonedStand.Parent = ScrollBackpack
				clonedStand.ImageLabel.Image = findingStand:GetAttribute("IMG")
				clonedStand.Name = v
				
				clonedStand.MouseButton1Click:Connect(function()
					putStandRequest:Fire(false,v)
					closeMenu(FondoBackpack)
				end)
				
			end
			
		end
		
	end)
	
	-- coins detect
	task.spawn(function()
		local CoinsBase : Frame = ScreenButtons:FindFirstChild("CoinsBase")
		local Base : ImageLabel = CoinsBase:FindFirstChild("Base")
		local TextLabel : TextLabel = Base:FindFirstChild("TextLabel")
		
		local Points = Players.LocalPlayer:FindFirstChild("Points")
		
		TextLabel.Text = "$"..AbbreviateModule:abbreviateNums(Points.Value)
		
		Points:GetPropertyChangedSignal("Value"):Connect(function()
			TextLabel.Text = "$"..AbbreviateModule:abbreviateNums(Points.Value)
		end)
		
	end)

	]]
end

return module

Can you please put a print statement:

  • At the start of the script
  • After all the requires within that script
  • After the trove.new thing
  • After all the remote things

and see which, if any, are delayed

Delete all the code, leave only the print statement and delete the trove. And it still takes a long time.


1 Like

Can you please show what the code looks like in its current state, after you removed some things? (code block, as before)

I found the error. Apparently, it depends on the remote module called “Warp.” It usually takes a while to load a remote because it uses a wait within the function.

1 Like

Yeah, that’s why I asked if you could add print statements at those various points

Thank you for taking the time to help me.

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