Problem with my gui

maybe change the color of slot.Parent.Frame?
I’m thinking we are changing the color of the wrong element.
Because from how it looks, slot is current the template and not actually the gui element.

Wait, is a table… remove the GetDescendants()

I suggest not making too many changes. I’d stay on track with what we had going.
We were so close. Seriously think “.Parent.Frame” was the last piece.

Clarification:

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] == true then
		slot.Parent.Frame.BackgroundColor3 = Color3.new(0,1,0)
	else
		slot.Parent.Frame.BackgroundColor3 = Color3.new(1,0,0)
	end
end

All your ducks are spawning on the gui. The only issue now is in our if else. If we have true and false values then we should see different colors. You could put a print in those if and else to verify if we see some true and some false. I believe we are changing the color of the wrong element, try slot.Parent.Frame. if that isn’t it take a closer look at the hierarchy of your gui to access the element you want.

so guys, to not make mistakes now i’ll create 2 script with your 2 different opinions(anyway thanks for helping me)

@CellBlT
it says this:
image

@jman3d your’s says this:

you cannot use “parent” at the beginning of an Instance.new

local slot = game.ReplicatedStorage.DucksUIHandler.Template:Clone()
	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]
    slot.Parent = script.Parent.Frame.Container

Ahhh okay. I was off with that one. Look what is the name of the element in DucksUIHandler.Template, you want to change the color of?

We just have to access it correctly. To verify this, run this code:

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] == 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
        print("if you only see red, and we should see both, we are accessing the wrong gui element")
end

It is not finding now the “Frame”

Post the results of the code here.


image

Remove the .Parent.Frame My bad. didnt mean to include that

1 Like

ok no problem ill try that now,


how u can see all the duck are red(i own more than half)

P.S.:
don’t mind the duck images, i didnt put them in the module

Hey one more little change so I can see everything. Remove the “if you only see red” print statement.

1 Like

ok sure!
image

BOOM! There you go. You aren’t seeing the other color because, you don’t have any duckies that satisfy your if condition ( no booleans values of true ).

The solution you ask? Well it looks like your Player.DucksFound isn’t housing the values you think it is. So rectifying that will fix everything.

1 Like

ehm, i don’t think so…
image

Are these values set with a LocalScript?

nope, a script in serverscriptservice

YOOOOOO set it to duckies[s].Value == true

BOOM. Thank me in a minute.

1 Like