I’m making a script where if a value is below a certain point, a red GUI will start to lose transparency.
Simple as this: It won’t work.
I’m only using the Developer Forum to get help right now. If possible, please help!
This is my script:
AirValue = game.Players.LocalPlayer.Character.Water.Air
TransparencyObj = script.Parent.LowOxygenEffect
while true do
if AirValue <= 35 then
TransparencyObj.BackgroundTransparency = AirValue / 35
elseif AirValue >= 35 then
TransparencyObj.BackgroundTransparency = 1
I’m going to add a limit to how opaque the GUI can get - but right now, I need this to be fixed.
I don’t see how anything is wrong with the script.
AirValue variable seems to refer to a value instance, not the actual number. Your if statement should look like this:
if AirValue.Value <= 35 then
Did you not get an error? I think you should have got one for comparing whether an instance is smaller than a number.
I just realized that and was going to fix and delete the post, thanks for helping though!
Should this work?
Don’t worry about “AirValue”, I’m going to fix that.
It does not work (I already edited the Air.Value).
on the statement
“if Air.Value <= 35 then”
is spelled wrong, It should be AirValue.Value not Air.Value
also happen in the else if condition
Also i recommned you using the function AirValue.Changed:Connect(function() instead of while looping through it to prevent some lag.
Someone else is helping me. It’s still not working.
hmm, very weird. what type of script is that and where is it located?
try this code example:
TransparencyObj.BackgroundTransparency = AirValue.Value / 35
You don’t need to put if and elseif condition since the outcome still the same, when the value reaches 35 it became whole invisible and when 0, its opaque.
Someone else is helping me.ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ
The things that @Legend_Allen has said are correct. And it might help if you answered his questions. Also, are you getting any error in the output window?
I’m using a seperate topic and forgot to close it, sorry.