How do I make one's transparency affect the other's?

I’m trying to make a UIStroke’s Thickness be affected by the Parent’s (Frame) Background Transparency. I tried writing a script already, it didn’t work unfortunately. This is urgent as I really need it for the game to function properly.

I tried this code, didn’t work.

lol = script.Parent.BackgroundTransparency
script.Parent.UIStroke.Thickness = lol

Screenshot 2021-12-25 134655
Screenshot 2021-12-25 134727

As you can see, the UIStroke still appears even though it’s Parent’s BackgroundTransparency is 0.

I’m going to assume that the Background transparency is changed since the start of the game, and you were hoping the thickness would too after it was changed. But no, this script will only change the thickness whenever the game starts therefore keeping the UIStroke’s thickness the same. So, use :GetPropertyChangedSignal() and go from there.

script.Parent:GetPropertyChangedSignal("BackgroundTransparency"):Connect(function()
    script.Parent.UIStroke.Thickness = script.Parent.BackgroundTransparency
end)
1 Like

It worked! But now, the Frame’s Background Transparency is 0, which also makes the Thickness 0. Before the script I made both the Background Transparency of the frame and the Thickness for the UIStroke 0.5, so it could look cooler.

Now the UIStroke only appears when the Frame’s BackgroundTransparency is 1, which also makes the UiStroke Thickness 0.

Sorry for all the words, hopefully this can be fixed as it makes the game really good.

Screenshot 2021-12-25 140216
Screenshot 2021-12-25 140227

Here’s the effect I wanna achieve:

Screenshot 2021-12-25 134655

2 Likes

Is there a way that you can make it so that when the Frame’s
BT (BackgroundTransparency) is 0, the UIStroke’s Thickness is 0.5, & when the Frame’s BT is 1, the UiStroke’s Thickness is 0?

@Kaid3n22

1 Like

oh, sure. Here’s the edited version:

local UIStroke = script.Parent.UIStroke

script.Parent:GetPropertyChangedSignal("BackgroundTransparency"):Connect(function()
    local transparency = script.Parent.BackgroundTransparency
    if transparency = 0  then
        UIStroke.Thickness = .5
    elseif transparency = 1 then
        UIStroke.Thickness = 0
    end
end)

Sorry for the late response (I was playing a game lol)

1 Like