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

Script changing Color3 values off the scale. Help?

Asked by 6 years ago

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!

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) UgOsMiLy 1074 — 6y
0
Thank you! It worked, I don't know why not with the first one but.. Thanks! :D wilsonsilva007 373 — 6y

1 answer

Log in to vote
0
Answered by
Tomstah 401 Moderation Voter
6 years ago

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.

0
To get the number for `Color3.new`, you need to do `num/255`. :) TheeDeathCaster 2368 — 6y
0
Thank you! It worked, I don't know why not with the first one but.. Thanks! :D wilsonsilva007 373 — 6y
Ad

Answer this question