How Tween Service color brightness of a mesh part

Can you share the full code you have so far? (Of the loop, I noticed you forgot to copy your end statement last time)

1. local v1 = 30
2. 		local v2 = 30
3. 		local v3 = 30
4. 		while Value ~=60 do
5. 			Value +=5
6. 			if v1 > 0 then
7. 				v1 = v1 - 1.5
8. 			end
9. 			if v2 > 0 then
10. 				v2 = v2 - 1.5
11. 			end
12. 			if v3 > 0 then
13. 				v3 = v3 - 1.5
14. 			end
15. 			task.wait(0.1)
16. 			local Model = CreateCloudModule.CreateStand(rv, 10, Value)
17. 			game.Debris:AddItem(Model,1)
18. 			task.wait(1)
19. 			local Parttween = {}
20. 			Parttween.Size = rv.CloudMunicipe.Size + Vector3.new(14.539, 9.464, 23)
21. 			Parttween.Position = rv.CloudMunicipe.Position + Vector3.new(0, 9.464, 0)
22. 			Parttween.Color = Color3.new(v1, v2, v3)
23. 			local partweninfo = TweenInfo.new(0.7, Enum.EasingStyle.Exponential)
24. 			local parttt = game:GetService("TweenService"):Create(rv.CloudMunicipe, partweninfo, Parttween)
25. 			parttt:Play()
26. 		end
27. 		if Value == 60 then
28. 			Value = 0
29. 		end

here

Line 22. Change Color3.new to Color3.fromRGB

What happens if you use
if Value >= 60
because if Value is changed somewhere else it may not be exactly 60, it might be 60.00000001

1 Like

this dont change nothing (i think), just for set value to 0 agein if i want to run the script agein

Yes, but when Value = 60.000000001 your if Value == 60 line returns false and it will never get reset to 0.

but i want to reset to 0 :nerd_face:
its ~= soo while it dont have any diference

I know you want it to reset to 0 when it gets to 60.
But if there are other calculations that cause floating point error it may not equal exactly 60 and when it doesn’t your value will keep going up.

You haven’t shown where Value is set, or if it’s part of another calculation.
I’m just saying it’s not a good practice when making calculations to require it to equal an exact number unless you have the value as an IntValue, or you round it so it always equals a whole number. Computers calculate in binary and when a decimal number is involved there’s a chance the decimal won’t calculate exactly.

In my example above, when Value is something like 59.99999999, or 60.00000001, your if Value == 60 line won’t be true and it won’t reset to 0.

For troubleshooting in your code just put a print(Value) inside your loop to see how Value is changing.