como posso otimizar esse script para que ele nao seja executado muitas vezes por segundo…
- User
como posso otimizar esse script para que ele nao seja executado muitas vezes por segundo ? : local Players = game:GetService("Players") local MarketplaceService = game:GetService("MarketplaceService")
local BillboardClientModule = script.Parent.BillboardClient local billboardClient = require(BillboardClientModule) local ad3DClient = require(script.Parent.Ad3DClient) local portalClient = require(script.Parent.PortalClient) local ConfigReader = require(script.Parent.ConfigReader) local AdRequestStats = require(script.Parent.AdRequestStats)
local REMOTES_FOLDER = "BloxbizRemotes"
local remotesFolder = game.ReplicatedStorage:WaitForChild(REMOTES_FOLDER) local newAdEvent = remotesFolder:WaitForChild("NewAdEvent") local update3DAdEvent = remotesFolder:WaitForChild("Update3DAdEvent") local updatePortalEvent = remotesFolder:WaitForChild("UpdatePortalEvent") local preloadAdsEvent = remotesFolder:WaitForChild("PreloadAdsEvent") local getSubscriptionProductInfoRemote = remotesFolder:WaitForChild("getSubscriptionProductInfo") local getSubsetClientPlayerStatsRemote = remotesFolder:WaitForChild("getSubsetClientPlayerStats") local getClientLogsRemote = remotesFolder:WaitForChild("getClientLogs")
local billboardAdUnits = ConfigReader:read("Ads")
local LocalPlayer = Players.LocalPlayer
local function initClientInstance(ad) task.spawn(function() local newBillboardClientModule = BillboardClientModule:Clone() newBillboardClientModule.Parent = script.Parent
local newBillboardClient = require(newBillboardClientModule) newBillboardClient:initAd(ad) end)end
local function clientLogsRequested(amount) local requestedLogs = {}
local clientLogs = game:GetService('LogService'):GetLogHistory() local numClientLogs = #clientLogs for i = amount, 1, -1 do local logToSend = clientLogs[numClientLogs - i + 1] table.insert(requestedLogs, logToSend) end return requestedLogsend
local function initClientEvents() newAdEvent.OnClientEvent:Connect(initClientInstance) getClientLogsRemote.OnClientInvoke = clientLogsRequested
game.Players.LocalPlayer.Idled:Connect(function(time) billboardClient:sendUserIdling(time) end) preloadAdsEvent.OnClientEvent:Connect(function(listToPreload) billboardClient:preloadList(listToPreload) end) getSubscriptionProductInfoRemote.OnClientInvoke = function(subscriptionId) local success, respose = pcall(function() return MarketplaceService:GetSubscriptionProductInfoAsync(subscriptionId) end) return success, respose end getSubsetClientPlayerStatsRemote.OnClientInvoke = function() return AdRequestStats:getSubsetClientPlayerStats() end update3DAdEvent.OnClientEvent:Connect(function(action, adBoxName, adToLoad) if action == "Construct" then ad3DClient.init(adBoxName, adToLoad) end end) updatePortalEvent.OnClientEvent:Connect(function(action, adBoxName, adToLoad) if action == "Construct" then portalClient.init(adBoxName, adToLoad) end end) - Assistant