I have this health scripting colors, and when the health changes color, it will tween to white first, and then tween to the next color (yellow,red), the first tween works (green,white,yellow) but the second tween won't (yellow,white,red), it seems that any color won't tween to the red color, but when I try tweening the red color to other colors, it works. Is there any problem with it?
elseif health >= 21 and health <=40 then healthcolor.ImageColor3 = Color3.new(255,255,0)--Yellow textbox.Text = 2 elseif health >= 1 and health <=20 then local tween = TweenService:Create(healthcolor, tweeninfo, {ImageColor3 = Color3.fromRGB(255,255,255)}) --Yellow tween to white tween:Play() wait(0.5)--Script wait until tween stop local tween = TweenService:Create(healthcolor, tweeninfo, {ImageColor3 = Color3.fromRGB(255,0,0)})--White tween to red tween:Play() wait(0.5)--Script wait until tween stop healthcolor.ImageColor3 = Color3.new(255,0,0) textbox.Text = 1 while true do textbox.TextColor3 = Color3.new(255,0,0) wait(0.5) textbox.TextColor3 = Color3.new(0,0,0) wait(0.5) end
Hello,
I see an Issue with your values of the colours. I'm not sure if it will fix your issue, but you can try at least.
Explanation
On the wiki, it states the following about color3.new(r,g,b)
Returns a Color3 with the given red, green, and blue values. The numbers can range from 0 to 1.
This basically is saying that all the values have to be between 0 and 1 for the RBG colour values. And in your script, for example Line 18:
healthcolor.ImageColor3 = Color3.new(255,255,0)--Yellow
it doesn't follow the 0 - 1 rule.
Solution To comply with this, all that has to be done is to divide your values by 255. 25/255 = 1, therefore the previous line of code I showcased should be :
healthcolor.ImageColor3 = Color3.new(1,1,0)--Yellow
. It's the same with ImageColor3.new(r,g,b)
However, when you are using
{ImageColor3 = Color3.fromRGB -- the values are raging from 0 - 255
Final Code
elseif health >= 21 and health <=40 then healthcolor.ImageColor3 = Color3.new(1,1,0)--Yellow textbox.Text = 2 elseif health >= 1 and health <=20 then local tween = TweenService:Create(healthcolor, tweeninfo, {ImageColor3 = Color3.fromRGB(255,255,255)}) --Yellow tween to white tween:Play() wait(0.5)--Script wait until tween stop local tween = TweenService:Create(healthcolor, tweeninfo, {ImageColor3 = Color3.fromRGB(255,0,0)})--White tween to red tween:Play() wait(0.5)--Script wait until tween stop healthcolor.ImageColor3 = Color3.new(1,0,0) textbox.Text = 1 while true do textbox.TextColor3 = Color3.new(1,0,0) wait(0.5) textbox.TextColor3 = Color3.new(0,0,0) wait(0.5) end
I hope this helps.
That's the only problem I see. Can you also show the output?