Wierd gradient issue (HELP NEEDED)

The gradient appears white when obviously enabled:

The button with ‘Off’ is the button that’s meant to have the red gradient. Yes, the gradient is a child of the button.

2 Likes

Can i see your script?

this comment was made by JustAGameDeveloper1 dont steal it

there is none, its just simply not showing even though it shows in edit mode

oh, okay.
can i see your explorer window?

image
the “Red” is the gradient that wont show, although if “Green” is enabled green shows (they have the same properties except color)

i see
try disabling “green”, this might solve your issue

I dont think you can overlap gradients, so this might help.

green isn’t enabled though. In test I went into my players player gui and it clearly showed Red was enabled. Could this be a bug?

Try giving red a higher zindex than green.

This could be a bug AFAIK.

Try increasing your ZIndex.

I came across this myself! You can’t have multiple gradients in the same UI element, no clue why. Simple fix is having them inserted by cloning them while they are parented to a localscript and setting the clone’s parent to the goal UI. Then, destroy the clone when switching gradients.

This post and staff solution says otherwise:

Odd. I had this problem roughly one week ago (way after that post), and my solution in my earlier response is what fixed it. Can’t hurt for OP to at least try, since it has at least worked for me, and my problem was exactly the same.

1 Like

I agree OP should try it for sure, you never know how these things behave with other ui elements.

Are you sure a script isn’t enabling the green also? While in play test, you should click into its properties to double check it hasn’t been enabled, or it will cancel out both gradients.

Edit: better yet just script one UIGradient element to change color as needed.

currently roblox overrides gradients on an instance even if it is enabled or disabled. what I did to fix this problem was to put the gradients inside a script and use a clone in the instance like this:

My Explorer:
image

Function on the script:

function ToggleGradients(enable : UIGradient)
	for i, gradient in pairs(script.Parent:GetChildren()) do
		if gradient:IsA("UIGradient") then
			gradient:Destroy() -- destroys all the gradients in the TextLabel
		end
	end
	if enable == nil then
		return
	end
	local NewGradient = enable:Clone() -- clones a gradient and puts it on the TextLabel
	NewGradient.Enabled = true
	NewGradient.Parent = script.Parent
end

Calling the function:
image

1 Like