Why does the BackgroundColor3 change when I set it to a specific value?
Asked by
4 years ago Edited 4 years ago
I have a script that detects key presses within a Frame, because of the nature of the game the key input can be either right or wrong, so, therefore, I change the background color of the GUI element to let the user know if the answer he submitted (through keypresses) was correct or not. Then I set the GUI element attribute "Visible" to false and change the color back to the original [48,48,48] in readiness for the next GUI element, however, the next time that same GUI element appears, the color looks like [255,255,255] but observing the value shows me some ridiculously high numbers in the tens of thousands.
I'm not sure why it is happening, so here's my code:
01 | local user_input = game:GetService( "UserInputService" ) |
04 | user_input.InputBegan:Connect( function (key_input) |
05 | if key_input.KeyCode = = Enum.KeyCode.F and picked = = false and script.Parent.Visible = = true then |
07 | script.Parent.BackgroundColor 3 = Color 3. new( 0 , 225 , 0 ) |
09 | game.ReplicatedStorage.OptionPicked:FireServer( true ) |
10 | script.Parent.Visible = false |
11 | script.Parent.BackgroundColor 3 = Color 3. new( 48 , 48 , 48 ) |
12 | elseif key_input.KeyCode = = Enum.KeyCode.G and picked = = false and script.Parent.Visible = = true then |
14 | script.Parent.BackgroundColor 3 = Color 3. new( 255 , 0 , 0 ) |
16 | game.ReplicatedStorage.OptionPicked:FireServer( true ) |
17 | script.Parent.Visible = false |
18 | script.Parent.BackgroundColor 3 = Color 3. new( 48 , 48 , 48 ) |
Here is the picture of the BackgroundColor3 value before and after:
Before key was pressed (Original color):
https://gyazo.com/bc0902afe740f86cf562def153af12fb
During key was pressed (Appears as [0,255,0]):
https://gyazo.com/aeb13a75c151faeb76798dc3aff66950
After key was pressed (Appears as [255,255,255]):
https://gyazo.com/12230b9a03afa91aca9017d97b1840a9