Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script fix- if command not working to change the color of a part. heres' your q mark?

Asked by 6 years ago
Edited by M39a9am3R 6 years ago

Here is the script that is not working.

ShieldCharge = script.Parent.Parent.ShieldHealth.ShieldCharge
TotalShield = script.Parent.TotalShield
Charge = script.Parent.Charge.Value
x = false

repeat
    if Charge >= 1 then
    ShieldCharge.part1.BrickColor = BrickColor.New("Toothpaste")        
    end
    wait(.5)
until x == true

Its meant to have a parts color to change to Toothpaste once Charge has reached one or greater. The Charge is a NumberValue which is constantly increasing, but that script is not in question.

Any and all help will be greatly appreciated!

-MyNameIsGuiseppe

0
Edited for code block. M39a9am3R 3210 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Try this:

ShieldCharge = script.Parent.Parent.ShieldHealth.ShieldCharge
TotalShield = script.Parent.TotalShield
Charge = script.Parent.Charge

repeat
    if Charge.Value >= 1 then
        ShieldCharge.part1.BrickColor = BrickColor.New("Toothpaste")
    end wait(0.5)
until Charge.Value >= 1 or ShieldCharge.part1.BrickColor == BrickColor.New("Toothpaste")

From my experience you can't get the value of the int unless returned from a function. This repeats the code until the value of charge is greater than or equal to 1. Then when charge is greater than or equal to one or the color of part1 was changed to Toothpaste it'll stop.

0
Thank you @gmatchOnRoblox! Mynameisguiseppe 15 — 6y
Ad

Answer this question