![]()
almost there!!!

So that error is telling us that duckies[s] was a nil value. It is saying we tried nil.Value on line 23 and you can’t access nil because its NOTHING!
Sooo I’m not exactly sure where the problem is lying but we can bandaid this thing if ur interested. I have a solution.
Send me your current code, I’ll apply a bandaid.
Sure
local Ducks = require(game.ReplicatedStorage:WaitForChild("DucksUIHandler"):WaitForChild("Ducks"))
local colors = {
EASY = Color3.fromRGB(25,190,0),
MEDIUM = Color3.fromRGB(255,170,0),
HARD = Color3.fromRGB(170,10,10),
MYTHICHAL = Color3.fromRGB(255,25,225),
LIMITED = Color3.fromRGB(255,255,255),
EXCLUSIVE = Color3.fromRGB(170,85,255),
}
local duckies = game.Players.LocalPlayer.DucksFound:GetChildren()
for s, duck in ipairs(Ducks) do
local slot = game.ReplicatedStorage.DucksUIHandler.Template:Clone()
slot.Parent = script.Parent.Frame.Container
slot.Name = duck.ID
slot.ImageLabel.Image = "rbxthumb://type=Asset&id="..duck.imageID.."&w=420&h=420"
slot.DifficultyLabel.Text = duck.difficulty
slot.Namef.Text = duck.name
slot.DifficultyLabel.BackgroundColor3 = colors[duck.difficulty]
if duckies[s].Value == true then
print("WOW WE SHOULD HAVE A GREEN DUCK")
slot.BackgroundColor3 = Color3.new(0,1,0)
else
print("WE SHOULD HAVE A RED DUCK")
slot.BackgroundColor3 = Color3.new(1,0,0)
end
end
Here you go feller.
local Ducks = require(game.ReplicatedStorage:WaitForChild("DucksUIHandler"):WaitForChild("Ducks"))
local colors = {
EASY = Color3.fromRGB(25,190,0),
MEDIUM = Color3.fromRGB(255,170,0),
HARD = Color3.fromRGB(170,10,10),
MYTHICHAL = Color3.fromRGB(255,25,225),
LIMITED = Color3.fromRGB(255,255,255),
EXCLUSIVE = Color3.fromRGB(170,85,255),
}
local duckies = game.Players.LocalPlayer.DucksFound:GetChildren()
for s, duck in ipairs(Ducks) do
local slot = game.ReplicatedStorage.DucksUIHandler.Template:Clone()
slot.Parent = script.Parent.Frame.Container
slot.Name = duck.ID
slot.ImageLabel.Image = "rbxthumb://type=Asset&id="..duck.imageID.."&w=420&h=420"
slot.DifficultyLabel.Text = duck.difficulty
slot.Namef.Text = duck.name
slot.DifficultyLabel.BackgroundColor3 = colors[duck.difficulty]
local success, response = pcall(function ()
if duckies[s].Value == true then
print("WOW WE SHOULD HAVE A GREEN DUCK")
slot.BackgroundColor3 = Color3.new(0,1,0)
else
print("WE SHOULD HAVE A RED DUCK")
slot.BackgroundColor3 = Color3.new(1,0,0)
end
end)
if success then
print("duck had no problem")
else
warn("duck had problem")
warn(response)
end
end
I’m excited to see the results here.
So what I did is I wrapped the code we know is going to throw an error. I wrapped it in a pcall. This is the try/catch of lua. try/catch is the way we can handle errors in our code. You want to have good code and handle errors appropriately with ifs and ur logics. So this pcall isn’t the nicest way to handle it but I think it’ll suffice.
I think I got it. So I think maybe DucksFound isn’t being instantiated quick enough. So by the time we are accessing it and making our gui, it doesn’t have all the bool values we would like to check.
local Ducks = require(game.ReplicatedStorage:WaitForChild("DucksUIHandler"):WaitForChild("Ducks"))
local colors = {
EASY = Color3.fromRGB(25,190,0),
MEDIUM = Color3.fromRGB(255,170,0),
HARD = Color3.fromRGB(170,10,10),
MYTHICHAL = Color3.fromRGB(255,25,225),
LIMITED = Color3.fromRGB(255,255,255),
EXCLUSIVE = Color3.fromRGB(170,85,255),
}
wait(5)
local duckies = game.Players.LocalPlayer.DucksFound:GetChildren()
for s, duck in ipairs(Ducks) do
local slot = game.ReplicatedStorage.DucksUIHandler.Template:Clone()
slot.Parent = script.Parent.Frame.Container
slot.Name = duck.ID
slot.ImageLabel.Image = "rbxthumb://type=Asset&id="..duck.imageID.."&w=420&h=420"
slot.DifficultyLabel.Text = duck.difficulty
slot.Namef.Text = duck.name
slot.DifficultyLabel.BackgroundColor3 = colors[duck.difficulty]
local success, response = pcall(function ()
if duckies[s].Value == true then
print("WOW WE SHOULD HAVE A GREEN DUCK")
slot.BackgroundColor3 = Color3.new(0,1,0)
else
print("WE SHOULD HAVE A RED DUCK")
slot.BackgroundColor3 = Color3.new(1,0,0)
end
end)
if success then
print("duck had no problem")
else
warn("duck had problem")
warn(response)
end
end
This is just to verify. I know there must be a more sophisticated means to do this besides wait(arbitrary amount of time).
yea no problem, im already happy because you are replying to me 
Any different results with the code provided?
I’m going to look into the proper solution for waiting. Try 10 let me see the duckies.
What is the name of your last duck/the name of the last boolean value you add. Still not sure this is the best way but it’ll be fool proof.
All duck worked but the last 2 don’t!
Maybe i need to put wait 10.5 and put a loading screen?
BTW the last duck is:
ID = “ComingSoon”
name = “Coming Soon”
badgeId = 0(for now)
Try this m8.
local Ducks = require(game.ReplicatedStorage:WaitForChild("DucksUIHandler"):WaitForChild("Ducks"))
local colors = {
EASY = Color3.fromRGB(25,190,0),
MEDIUM = Color3.fromRGB(255,170,0),
HARD = Color3.fromRGB(170,10,10),
MYTHICHAL = Color3.fromRGB(255,25,225),
LIMITED = Color3.fromRGB(255,255,255),
EXCLUSIVE = Color3.fromRGB(170,85,255),
}
game.Players.LocalPlayer.DucksFound:WaitForChild("ComingSoon")
local duckies = game.Players.LocalPlayer.DucksFound:GetChildren()
for s, duck in ipairs(Ducks) do
local slot = game.ReplicatedStorage.DucksUIHandler.Template:Clone()
slot.Parent = script.Parent.Frame.Container
slot.Name = duck.ID
slot.ImageLabel.Image = "rbxthumb://type=Asset&id="..duck.imageID.."&w=420&h=420"
slot.DifficultyLabel.Text = duck.difficulty
slot.Namef.Text = duck.name
slot.DifficultyLabel.BackgroundColor3 = colors[duck.difficulty]
local success, response = pcall(function ()
if duckies[s].Value == true then
print("WOW WE SHOULD HAVE A GREEN DUCK")
slot.BackgroundColor3 = Color3.new(0,1,0)
else
print("WE SHOULD HAVE A RED DUCK")
slot.BackgroundColor3 = Color3.new(1,0,0)
end
end)
if success then
print("duck had no problem")
else
warn("duck had problem")
warn(response)
end
end
If it works let me see the glorious duck ui.
Alright, the ui needs seconds to load(its fine for me) but the output says this:
All the ducks are working!
Well great! I’d love to see a photo of the gui with all the ducks. Satisfying.
In your serversidescript that sets the boolean values, what is the name of the last value you add/set there?
but the infinite yield? its fine?
Booleans:

server side script:
local BadgeService = game:GetService("BadgeService")
local DucksService = require(game.ReplicatedStorage.DucksUIHandler.Ducks)
local function setup(player: player)
local UserID = player.UserId
local key = "Player_"..UserID
local f = Instance.new("Folder",player)
f.Name = "DucksFound"
for _, id in ipairs(DucksService) do
local l =Instance.new("BoolValue", f)
l.Name = id.ID
l.Value = if BadgeService:UserHasBadgeAsync(UserID, id.badgeID) then true else false
end
end
game.Players.PlayerAdded:Connect(setup)
If someone knows a better solution please come along and enlighten us.
Until then here is an idea:
server side script:
local BadgeService = game:GetService("BadgeService")
local DucksService = require(game.ReplicatedStorage.DucksUIHandler.Ducks)
local function setup(player: player)
local UserID = player.UserId
local key = "Player_"..UserID
local f = Instance.new("Folder",player)
f.Name = "DucksFound"
for _, id in ipairs(DucksService) do
local l =Instance.new("BoolValue", f)
l.Name = id.ID
l.Value = if BadgeService:UserHasBadgeAsync(UserID, id.badgeID) then true else false
end
local lastValue = Instance.new("BoolValue", f)
lastValue.Name = "LastBool"
end
game.Players.PlayerAdded:Connect(setup)
duckui:
local Ducks = require(game.ReplicatedStorage:WaitForChild("DucksUIHandler"):WaitForChild("Ducks"))
local colors = {
EASY = Color3.fromRGB(25,190,0),
MEDIUM = Color3.fromRGB(255,170,0),
HARD = Color3.fromRGB(170,10,10),
MYTHICHAL = Color3.fromRGB(255,25,225),
LIMITED = Color3.fromRGB(255,255,255),
EXCLUSIVE = Color3.fromRGB(170,85,255),
}
game.Players.LocalPlayer.DucksFound:WaitForChild("LastBool")
game.Players.LocalPlayer.DucksFound.LastBool:Destroy()
local duckies = game.Players.LocalPlayer.DucksFound:GetChildren()
for s, duck in ipairs(Ducks) do
local slot = game.ReplicatedStorage.DucksUIHandler.Template:Clone()
slot.Parent = script.Parent.Frame.Container
slot.Name = duck.ID
slot.ImageLabel.Image = "rbxthumb://type=Asset&id="..duck.imageID.."&w=420&h=420"
slot.DifficultyLabel.Text = duck.difficulty
slot.Namef.Text = duck.name
slot.DifficultyLabel.BackgroundColor3 = colors[duck.difficulty]
local success, response = pcall(function ()
if duckies[s].Value == true then
print("WOW WE SHOULD HAVE A GREEN DUCK")
slot.BackgroundColor3 = Color3.new(0,1,0)
else
print("WE SHOULD HAVE A RED DUCK")
slot.BackgroundColor3 = Color3.new(1,0,0)
end
end)
if success then
print("duck had no problem")
else
warn("duck had problem")
warn(response)
end
end
Also not sure, but there may be an end missing in the serversidescript??
So what I did was make it to where we know the last element being added. We wait for that element to be created in the ui script. When it is added, we remove it, and then process all the ducks you wanted.
i edited the server script becasue in line 18 there was l instead of lastValue and i got this now:
(With no ducks)
LOL! I deleted the wrong thing. Change .DucksFound:Destroy() to .DucksFound.LastBool:Destroy()
I edited the previous code snippet.












