Transparency Change Not Working?

I’ve been trying to make it so that whenever there is a specific item added into the players collected folder. A GUI goes from transparency 1 to 0.75, However it doesn’t work. but when i try to do the opposite (Change the transparency from 0.75 to 1) It works.

This isn’t the entire script but heres the part of the script I’m having problems with

if oxiansCollected:FindFirstChild(itemName) then
		Itembutton.collected.BackgroundTransparency = 0.75
	else
		Itembutton.collected.BackgroundTransparency = 1
	end

Do this:

if oxiansCollected:FindFirstChild("itemName") then
		Itembutton.collected.BackgroundTransparency = 0.75
	else
		Itembutton.collected.BackgroundTransparency = 1
	end

It could work, or the opposite.
I mean, what’s your full script?

1 Like
local IndexMenu = script.Parent
local scrollingFrame = script.Parent
local info = script.Parent.Parent.Info
local collected = script.Parent.Parent.Text.Collected
local UIGridLayout = script.Parent.UIGridLayout

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local replicatedStorage = game:GetService("ReplicatedStorage")
local oxiansFile = replicatedStorage:WaitForChild("Oxians")

local difficultyColors = {
	Color3.fromHex("#00ff40"), -- Its Right There
	Color3.fromHex("#00c70d"), -- Easy
	Color3.fromHex("#d1c300"), -- Medium
	Color3.fromHex("#f37a00"), -- Hard
	Color3.fromHex("#f30000"), -- Difficult
	Color3.fromHex("#f100a9"), -- Insane
	Color3.fromHex("#f100a9") -- Bro?
}

local difficulties = {
	"Its Right There",
	"Easy",
	"Medium",
	"Hard",
	"Difficult",
	"Insane",
	"Bro?"
}

local oxiansCollected = player:WaitForChild("oxiansCollected")

local totalCount = 0
for i, v in pairs(oxiansFile:GetChildren()) do
	totalCount = totalCount + 1
end

local collectedCount = 0
for i, v in pairs(oxiansCollected:GetChildren()) do
	collectedCount = collectedCount + 1
end

collected.Text = collectedCount.."/"..totalCount.." Found"

for i, item in pairs(oxiansFile:GetChildren()) do
	
	local itemName = item.Name
	local difficulty = item.difficulty.Value
	local hint = item.hint.Value
	local name = item.name.Value
	local Image = item.image.Texture
	local description = item.description.Value
	
	local Itembutton = script.Template:Clone()
	
	Itembutton.Parent = scrollingFrame
	Itembutton.Name = itemName
	Itembutton.Image = Image
	Itembutton.difficulty.BackgroundColor3 = difficultyColors[difficulty]
	
	if oxiansCollected:FindFirstChild(itemName) then
		Itembutton.collected.BackgroundTransparency = 0.75
	else
		Itembutton.collected.BackgroundTransparency = 1
	end
	Itembutton.LayoutOrder = difficulty
	UIGridLayout.SortOrder = Enum.SortOrder.LayoutOrder
	UIGridLayout:ApplyLayout()
	
	Itembutton.MouseButton1Up:Connect(function()
		info.Visible = true
		IndexMenu.Visible = false
		info.itemImage.Image = Image
		info.Hint.Text = "Hint: "..hint
		info.difficulty.BackgroundColor3 = difficultyColors[difficulty]
		info.difficulty.Text = "Difficulty: "..difficulties[difficulty]
		info.description.Text = "Description: "..description
		info.Nayum.Text = name
	end)
end

oxiansCollected.ChildAdded:Connect(function(child)
	collectedCount = collectedCount + 1
	collected.Text = collectedCount.."/"..totalCount.." Found"
	local childButton = scrollingFrame:FindFirstChild(child.Name)
	childButton.collected.BackgroundTransparency = 1
end)

Also, there’s an issue when I try to open the frame, it errors, I mean warn.

Infinite yield possible on 'Players.kdopdaux1803:WaitForChild(“oxiansCollected”)

1 Like

This should be a simple fix.

add another script with the same code but reverse the if statement so the chunk in the else is now in the if, and the chunk in the if is now in the else.

1 Like

I’m sorry but i don’t get what your saying.

Use this LocalFile, I PM’ed @VlogcksAllOverAgain to make a LocalFile:

World.rbxl

1 Like

U can reverse the if statement in two different scripts if everything else you tried didn’t work

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.