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

button text color 3 not chaching back to its orginal value?

Asked by
hokyboy 270 Moderation Voter
4 years ago

sorry im on mobile now cause my internet on pc fell off so sorry For bad formatting

so i have this script if some ones enters my button with their mouse the background color chanches but it doesnt change back why

script.Parent.MouseButton1Click:Connect(function()

script.Parent.Text = "You Clicked Me"

end)

script.Parent.MouseEnter:Connect(function()

script.Parent.BackgroundColor3 = Color3.new(58, 58, 58)

end)

script.Parent.MouseLeave:Connect(function()

script.Parent.BackgroundColor3 = Color3.new(120, 120, 120)

end)

2 answers

Log in to vote
0
Answered by
mc3334 649 Moderation Voter
4 years ago

Hello Hokyboy! There are a couple things I see that could be the cause for your problems. The main one, is you using Color3.new(). This is one of the things I see most often and is always confused with Color3.fromRGB(). The values you provided look like red green blues, so try replacing the .new() with .fromRGB(). When you do use color3.new(), it accepts values from 0-1 for R,G,B. When you you use fromRGB(), it takes numbers from 0-225. I hope this helped. If you need further assistance or have any questions/comments/concerns, please reply to my post. ~mc3334

Ad
Log in to vote
-1
Answered by 4 years ago
Edited 4 years ago

It's better to use Color3.fromRGB(number x, number y, number z). It accept values from 0 - 255. For example, if you were using Color3.fromRGB(), then it goes like this.

script.Parent.BackgroundColor3 = Color3.fromRGB(0,0,0) 
--This would be Black.

script.Parent.BackgroundColor3 = Color3.fromRGB(0,255,0) 
--This would be Lime Green.

script.Parent.BackgroundColor3 = Color3.fromRGB(100,100,100) 
--This would be Greyish.

Answer this question