I made a script that enables/disables UI gradients depending on the a value. However, the gradients don’t appear unless a certain one is loaded. I have all of the gradients parented to a frame, and no gradients appear unless the first one is enabled/loaded.
Apologies if something didn’t make sense.
Example:
In studio
On play
It’s enabled on play, and in studio, but it doesn’t appear.
It doesn’t just apply to that one gradient, it applies to all others except the first child.
How could I fix this issue? It’s incredibly annoying and makes my game really weird.
I don’t think it’s a loading issue as it doesn’t load no matter how much time I give it.
Thanks!
I can’t provide the entire thing, but it works somewhat like this:
local frame = script.Parent.Parent.ItemViewport:WaitForChild("Frame")
local function disableOthers()
for i,v in pairs(frame:GetChildren()) do
v.Enabled = false
end
end
script.Parent:GetPropertyChangedSignal("Value"):Connect(function()
if script.Parent.Value == "test" then
disableOthers()
frame:FindFirstChild("UIGradientExample1").Enabled = true
-- and so on with
elseif script.Parent.Value == "test2" then
disableOthers()
frame:FindFirstChild("UIGradientExample2").Enabled = true
end
end)
I don’t think it’s the script’s issue, as I disabled it and the gradient still didn’t load. I don’t have the time now, but I’ll check if other gradients are working for other frames.
Your script works perfectly fine and I am getting the same problem as you. I tried enabling and disabling it manually in studio and the gradients aren’t changing unless the StringValue is set equal to the first option. I will try to find a work around though.
Huh. UIGradients work on other frames. I tried moving the frame out and then back into the ViewportFrame, and the gradients don’t show in studio anymore.
So what I did was that I just kept one UIGradient and changed the colors whenever the StringValue changes rather than enabling/disabling multiple gradients.