Game Lagging due to "Check" scripts

Hello ROBLOX Developer forum community!
My game has become very laggy because of the check gamepass scripts spamming the Developer Console. Is there something that can happen to fix that?

Script Example:

local Market = game:GetService(“MarketplaceService”)
local Pass = = 00000000 – gamepass ID

game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if Market:UserOwnsGamePassAsync(Player.UserId, Pass) == true then
script.Tag:WaitForChild(“PremiumTag”):Clone().Parent = Character.Head
end
end)
end)


Could you supply the (formatted) actual code that’s running in your game? It looks like there’s probably a LOT of unnecessary, frequent checks that are happening. We can’t help you debug this if you provide pseudo code. For example, where are the prints to the console? That would be immensely helpful :smiley:

2 Likes

Where could I contact you so we can have talk?

1 Like

Go to their profile by clicking user icon and click message then write your message. and he will reply so you can talk with him in a private message such as contact.

Reply to Hero_GG instead of me.

Sorry lol i didnt saw to who i was Replying

1 Like

the game LAG because of functions

make sure u do wait() so it cant cause that lag

1 Like

This is not going to help. The issue is because you’re checking each individual gamepass every time a character loads.

For the sake of web calls per second that you’re allowed to make I suggest only checking what gamepasses they own when they join the game. And, maybe don’t clone the same script 100 times and give it different gamepass ids…

1 Like