Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

code will not work if i add if statement?

i have a gas mask gui i want to appear when you equip a tool. I have that set up. However, I am also making a bar appear when you equip the tool and when the bar is completely filled up, the gui will appear on your screen. here is my code:

if script.Parent.Parent.bool == true then
	while true do
		wait(0.25)
		MeterA = MeterA + 1
		if MeterLocation:FindFirstChild("Meter"..MeterB) then
			MeterLocation["Meter"..MeterB].ImageTransparency = 0
			MeterB = MeterB - 1
		end
				if MeterA == 19 then
		script.Parent.Visible = false
		MeterA = 0
		MeterB = 19
		end
		end
		end

see, the code works fine UNTIL I add the if statement, even if the value is true. there are no errors in output. Help would be helpful

1 comment

0

bool is a boolvalue btw\

1 answer

✓ Accepted answer

You need to reference the .Value property of a BoolValue to actually attain the information it holds.

if script.Parent.Parent.bool.Value == true then
    while true do
        wait(0.25)
        MeterA = MeterA + 1
        if MeterLocation:FindFirstChild("Meter"..MeterB) then
            MeterLocation["Meter"..MeterB].ImageTransparency = 0
            MeterB = MeterB - 1
        end
                if MeterA == 19 then
        script.Parent.Visible = false
        MeterA = 0
        MeterB = 19
        end
        end
        end

2 comments

0

oops lol

2

man i need to assess my problems before actually coming to scripting helpers

This discussion is preserved as it was. New answers, comments, and votes are closed.