Hi, I am trying to fix an index for a “find the” game. but I keep running into this error and I’ve never edited the script before. if anyone wants to take a look and help me I will greatly appreciate it (error is in line 64)
local BadgeService = game:GetService("BadgeService")
local player = script.Parent.Parent.Parent.Parent.Parent
local UserId = player.UserId
local owned = script.Owned
local total = script.Total
script.Owned:GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.Parent.Amount.Text = tostring(owned.Value).."/"..tostring(total.Value)
end)
for _,flag in pairs (workspace.Flags:GetChildren()) do
total.Value = total.Value +1
local template = game.ServerStorage.FlagTemplate:Clone()
local BadgeId = flag.BadgeID.Value
template.Name = flag.Name
template.FlagName.Text = flag.Name
template.Parent = script.Parent.Frame
template.ImageLabel.Image = flag.Decal.Texture
template.Description.Value = flag.Description.Value
if flag.Difficulty.Value == "Easy" then
template.Difficulty.Text = flag.Difficulty.Value
template.LayoutOrder = -9
template.Difficulty.TextColor3 = Color3.fromRGB(31, 128, 29)
elseif flag.Difficulty.Value == "Medium" then
template.Difficulty.Text = flag.Difficulty.Value
template.LayoutOrder = -8
template.Difficulty.TextColor3 = Color3.fromRGB(248, 207, 109)
elseif flag.Difficulty.Value == "Hard" then
template.Difficulty.Text = flag.Difficulty.Value
template.LayoutOrder = -7
template.Difficulty.TextColor3 = Color3.fromRGB(196, 40, 28)
elseif flag.Difficulty.Value == "Very Hard" then
template.Difficulty.Text = flag.Difficulty.Value
template.LayoutOrder = -6
template.Difficulty.TextColor3 = Color3.fromRGB(170, 0, 0)
elseif flag.Difficulty.Value == "Insane" then
template.Difficulty.Text = flag.Difficulty.Value
template.LayoutOrder = -5
template.Difficulty.TextColor3 = Color3.fromRGB(153, 0, 229)
elseif flag.Difficulty.Value == "Extreme" then
template.Difficulty.Text = flag.Difficulty.Value
template.LayoutOrder = -4
template.Difficulty.TextColor3 = Color3.fromRGB(0, 0, 141)
elseif flag.Difficulty.Value == "Terrifying" then
template.Difficulty.Text = flag.Difficulty.Value
template.LayoutOrder = -3
template.Difficulty.TextColor3 = Color3.fromRGB(74, 240, 255)
elseif flag.Difficulty.Value == "Catastrophic" then
template.Difficulty.Text = flag.Difficulty.Value
template.LayoutOrder = -2
template.Difficulty.TextColor3 = Color3.fromRGB(0, 0, 0)
elseif flag.Difficulty.Value == "😈" then
template.Difficulty.Text = flag.Difficulty.Value
template.LayoutOrder = -1
template.Difficulty.TextColor3 = Color3.fromRGB(27, 42, 53)
end
if BadgeId ~= 0 then
coroutine.resume(coroutine.create(
function()
if BadgeService:UserHasBadgeAsync(UserId, BadgeId) then
task.wait()
template.BackgroundColor3 = Color3.fromRGB(0,255,0)
owned.Value = owned.Value+1
end
end
))
script.Parent.Parent.Amount.Text = owned.Value.."/"..total.Value
end
script.Parent.Parent.Amount.Text = tostring(owned.Value).."/"..tostring(total.Value)
end
This means that you are too quick to check if the player has a badge. If I’m not mistaken, it’s 100 request in 1 minute. Try to limit your queries. If you tell me exactly how you use this function, then I can probably help you better.
basically, it checks if the player has the badge and changes the backround colour in the index, i followed a tutorial but the code just started breaking after adding more items to the index. me and my cousin have been trying to fix it but no success and I dont even under stand it at this point
but there isnt really anything i can do as the game is a pass type game and the entire thing depends on gamepasses. so i guess i cannot add any more items?
This is local script or server script?
Edit: See, local, I don’t see another option, how to make them less than 100 (99 is possible) and before starting the script, make a table where to write whether the player has a gamepass or not, and then check the table already, and not call the function
Could you explain what this script is about, what is his usage, and why do you need to check if the user has all theses badges without any action from the user itself?