Ad
Log in to vote
0

Why does the background color turn white instantly?

Asked by 9 days ago

Hello, every part of the script is responding well to eachother except the line where it changes the color to (30, 182, 20) which is a medium-dark green. Every time I run the script, it turns the button completely white, and the background color says (6500, 0, 0).

Player = game.Players.LocalPlayer --get the local player
color = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("WhatColor")
script.Parent.MouseButton1Up:connect(function()


    if color.Value == "Green" then
        script.Parent.BackgroundColor3 = Color3.new(240, 0, 0)
        color.Value = "Red"
        script.Parent.Text = "Game Off"
        Player.Ingame.Value = false

    elseif color.Value == "Red" then

        script.Parent.BackgroundColor3 = Color3.new(30, 182, 20)
        color.Value = "Green"
        script.Parent.Text = "Game On"
        Player.Ingame.Value = true
    end





end)

Hi.

Looks like you're using an ad blocker.

That's fine...

No, it really is.

Just, I mean, we put a lot of work into this site, you know?

It would be really really appreciated if you would turn off your ad blocker for our website...

We tried really hard to make our ads as unobtrusive as possible.

If you really hate ads, would you consider a $2 donation via Patreon?

Here's the link.

We love you. We hope you love us too.

.

..

...

Now back to your regularly scheduled Scripting Helpers....

...

..

.

1 answer

Log in to vote
0
Answered by 9 days ago
Player = game.Players.LocalPlayer --get the local player
color = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("WhatColor")
script.Parent.MouseButton1Up:connect(function()
    if color.Value == "Green" then
        script.Parent.BackgroundColor3 = Color3.fromRGB(240, 0, 0)
        color.Value = "Red"
        script.Parent.Text = "Game Off"
        Player.Ingame.Value = false
    elseif color.Value == "Red" then
        script.Parent.BackgroundColor3 = Color3.fromRGB(30, 182, 20)
        color.Value = "Green"
        script.Parent.Text = "Game On"
        Player.Ingame.Value = true
    end
end)

OR

Player = game.Players.LocalPlayer --get the local player
color = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("WhatColor")
script.Parent.MouseButton1Up:connect(function()
    if color.Value == "Green" then
        script.Parent.BackgroundColor3 = Color3.new(240/255, 0/255, 0/255)
        color.Value = "Red"
        script.Parent.Text = "Game Off"
        Player.Ingame.Value = false
    elseif color.Value == "Red" then
        script.Parent.BackgroundColor3 = Color3.new(30/255, 182/255, 20/255)
        color.Value = "Green"
        script.Parent.Text = "Game On"
        Player.Ingame.Value = true
    end
end)

Either method above works, it gets the exact color value that you specify.

0
use color3.fromRGB it's faster cuz you don't need to use math to put parameters in hiimgoodpack 1378 — 9d
0
use local variables hiimgoodpack 1378 — 8d
Ad

Answer this question



Ad