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

Script changing Color3 values off the scale. Help?

I have this portion of my script:

if health <= 30 then
		script.Parent.BackgroundColor3 = Color3.new(255,0,0)
		script.Parent.Shadow.BackgroundColor3 = Color3.new(223,0,0)
	end

It changes the color of the Script.Parent wich is a bar, but when trying to change the color of the script.Parent.Shadow it just changes the color to (0,25623,0). Both are frames and were copy pasted Why is this happening? Can someone help me?

Thanks!

2 comments

0

Use Color3.fromRGB() . With Color3.new(), the arguments have to be between 0 and 1, so all values are multiplied by 255. The solution is Color3.fromRGB(255,0,0)

0

Thank you! It worked, I don't know why not with the first one but.. Thanks! :D

1 answer

✓ Accepted answer

ROBLOX has an odd system, instead of the typical 255 system, they have it set up so that it needs to be in a range of 0 - 1 instead of 0 - 255 with the default constructor Color3.new().

Color3.new(number r, number g, number b) Color3.fromRGB(int r, int g, int b)

For Color3.new, it needs to be a number from 0 - 1, or you get odd results, however you can use Color3.fromRGB() which will get you the results you want.

2 comments

0

To get the number for Color3.new, you need to do num/255. :)

0

Thank you! It worked, I don't know why not with the first one but.. Thanks! :D

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