Issue inserting the Color3 values

I made this script

Script
print(tool.Handle.Color.R,tool.Handle.Color.G,tool.Handle.Color.B)
								
								local ColoreR = tool.Handle.Color.R
								local ColoreG = tool.Handle.Color.G
								local ColoreB = tool.Handle.Color.B
								print(ColoreR,ColoreG,ColoreB)

								
								if ColoreR < 1 then
									ColoreR = tool.Handle.Color.R+(((tool.HP.Value-100)*-1)/100)
								end
								
								if ColoreG < 1 then
									ColoreG = tool.Handle.Color.G+(((tool.HP.Value-100)*-1)/100)
								end
								
								if ColoreB < 1 then
									ColoreB = tool.Handle.Color.B+(((tool.HP.Value-100)*-1)/100)
								end
								print(ColoreR,ColoreG,ColoreB)
								print(tool.Handle.Color)

Basically checks the Color3 of the tool i’m using and according to his hp (max is 100) (1 click = hp-1)
he will increase the values that are less than 1(color3 value)
At the end the tool will become totally white, losing his original color.

So if i click 10 times the value will be 0.1,0.1,0.1 [Using Black Tool]
35 times will be 0.35,0.35,0.35 [Black Tool, now Gray]

Using a Really Red Tool will be 1,0.35,0.35 [Around Pink]

That’s fantastic, yes, but when i insert in the script this

tool.Handle.Color = Color3.new(ColoreR,ColoreG,ColoreB)

The values totally go increasing randomly

Here some photos about this:

1

Without the last code line, as you can see i clicked 11 times using a Really Red Tool
Output = the color3 is [1,0.11,0.11]

2
With the last code line, clicked exactly 10 times, got the hell.

Does anyone know how to fix this problem? thanks in advance.

I’m pretty sure I read somewhere that this is a floating point issue and can’t really be fixed by a developer (unless you do something hacky)

Looks like Roblox is working on a possible fix

1 Like

I think i fixed it. Now seems working proprely

								if tool.HP.Value == 99  then
									OriginalR = tool.Handle.Color.R
									OriginalG = tool.Handle.Color.G
								    OriginalB = tool.Handle.Color.B
									NotOriginal = false
								end
								
								if NotOriginal == false then
									 ColoreR = OriginalR
									 ColoreG = OriginalG
									 ColoreB = OriginalB
									NotOriginal = true
								end
								if NotOriginal == true then
										
									if ColoreR < 0.95 and (tool.Handle.Color.R*255) < 250 and (ColoreR*255) < 250  then
										ColoreR = OriginalR+(((tool.HP.Value-100)*-1)/100)
									end
									
									if ColoreG < 0.95 and (tool.Handle.Color.G*255) < 250 and (ColoreG*255) < 250  then
										ColoreG = OriginalG+(((tool.HP.Value-100)*-1)/100)
									end
									
									if ColoreB < 0.95 and (tool.Handle.Color.B*255) < 250 and (ColoreB*255) < 250 then
										ColoreB = OriginalB+(((tool.HP.Value-100)*-1)/100)
									end
									print(ColoreR,ColoreG,ColoreB)
									print(ColoreR*255,ColoreG*255,ColoreB*255)
									tool.Handle.Color = Color3.new(ColoreR,ColoreG,ColoreB)
									print(ColoreR,ColoreG,ColoreB)
									print(tool.Handle.Color)
									print("-----------------------------")
									
								end
2 Likes