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

Why doesn't this script set Color3 to blue, and instead turns it white?

Asked by 4 years ago

I have a script that plays a sound every time you scroll. There's also a script that allows you to turn off the sound. If the script is disabled, the button turns red, but if the script isn't disabled, it should turn blue. Although it just turns white. Here's the script:


script.Parent.MouseButton1Click:Connect(function() if script.Parent.Parent.Parent.Parent.Parent.PlayerScripts.ScrollSound.Disabled == false then script.Parent.Parent.Parent.Parent.Parent.PlayerScripts.ScrollSound.Disabled = true script.Parent.Text = "Scroll Sound Effect: OFF" script.Parent.BackgroundColor3 = Color3.new(255, 0, 0) elseif script.Parent.Parent.Parent.Parent.Parent.PlayerScripts.ScrollSound.Disabled == true then script.Parent.Parent.Parent.Parent.Parent.PlayerScripts.ScrollSound.Disabled = false script.Parent.Text = "Scroll Sound Effect: ON" script.Parent.BackgroundColor3 = Color3.new(20, 141, 255) end end)
0
im sorry but this kinda hurts to read Fifkee 2017 — 4y
0
Use Color3.fromRGB(100,100,100) or divide your values by 255 Thetacah 712 — 4y
0
^^ just view source NoahsRebels 99 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

Color3 is a roblox data type. Color3.new() creates a color by taking a percetange, meaning that the three values must be between 0 and 1. I can see that you are trying top change the color using rgb numerical coding. The old method to fixing this was to put the numbers out of 255, so it would look like this:

Color3.new(20/255,141/255,255/255)

This created a number between 0 and 1 and it was used to create desired colors. Nowadays roblox has evolved so now Color3 has a function called fromRGB(). By using this you can create your desired color using rgb numerical coding like so:

Color3.fromRGB(20,141,255)

TL;DR Use Color3.fromRGB()

I hope my answer was helpful

~Lone

0
It was! Thank you for the response NoahsRebels 99 — 4y
Ad

Answer this question