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

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

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

1 comment

0

Edited for code block.

1 answer

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.

1 comment

0

Thank you @gmatchOnRoblox!

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