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

BackgroundColor3 On My Frame Not Changing, Help?

Asked by
commag 228 Moderation Voter
8 years ago
function ColourChange()
    repeat R = R+1 wait(0.1) game.StarterGui.Intro.Background.BackgroundColor3 = Color3.new(R,G,B) until R == 255
    if R == 255 then
    repeat B = B+1 wait(0.1) game.StarterGui.Intro.Background.BackgroundColor3 = Color3.new(R,G,B) until B == 255
    if R == 255 and B == 255 then
    repeat G = G+1 wait(0.1) game.StarterGui.Intro.Background.BackgroundColor3 = Color3.new(R,G,B) until G == 255
    if R == 255 and B == 255 and G == 255 then
    repeat R = R-1 wait(0.1) game.StarterGui.Intro.Background.BackgroundColor3 = Color3.new(R,G,B) until R == 0
    if R == 0 and B == 255 and G == 255 then
    repeat B = B-1 wait(0.1) game.StarterGui.Intro.Background.BackgroundColor3 = Color3.new(R,G,B) until B == 0
    if R == 0 and B == 0 and G == 255  then
    repeat G = G-1 wait(0.1) game.StarterGui.Intro.Background.BackgroundColor3 = Color3.new(R,G,B) until G == 0
    end

    end
    end
end

game.Players.PlayerAdded:connect(function()

repeat wait() until game.Players.LocalPlayer:FindFirstChild("PlayerGui")

 R = 0
 B = 0
 G = 0



repeat ColourChange() until game.StarterGui:FindFirstChild("Intro")

end)

I don't understand why it wont work. Basically I'm making An Intro and I want my background to change color gradually over time... The Parent Of This Script Is Workspace. Is it because I'm changing the starter gui and not the player gui or something else????????? I'm Really Stuck With This One

0
Ding! Ding! Ding! You guessed it. Changes made in StarterGui won't follow over to the player. Meltdown81 309 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago
Edited 8 years ago

It's probably because the Color3 constructor takes three numbers between 0 and 1. You could divide your numbers by 255, or use Color3.fromRGB.

Apart from that, there's also a Color3:lerp method that would work much better than what you're currently doing.

Here's an example:

local StartColor = Color3.new(1,0,0)-- Red
local EndColor = Color3.new(0,0,1)-- Blue

local Frame = script.Parent

for i = 0,1,0.03 do
    wait()
    Frame.BackgroundColor3 = StartColor:lerp(EndColor,i)
end
Ad

Answer this question