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

[Solved] Why is my Color3 not setting correctly?

Asked by
PastDays 108
4 years ago
Edited 4 years ago

No matter how long I develop games for I can never seem to understand the changing of colours, Brickcolor, Color3 etc... I always seem to do it wrong.

I am trying to take RGB from a frames BackgroundColor3 and set a Decals Color3 RGB to it, even though they are both RGB the BackgroundColor3 seems to return a number between 0 and 1.

Any help and explanation would be greatly appreciated.

-- FIX

script.Color.Value = children[i].BackgroundColor3
                        game.ReplicatedStorage.Stored_Assets.Player_Assets.Character.Colour.Color3 = Color3.fromRGB(script.Color.Value.R*255,script.Color.Value.G*255,script.Color.Value.B*255)

Times the output of BackgroundColor3 by 255 and it will return the correct RGB.

local children = script.Parent:GetChildren()
local PlayerName = game.Players.LocalPlayer.Name
local Debounce = true

while true do wait()
    for i = 1, #children do
        if children[i].ClassName == "TextButton" then
            children[i].MouseButton1Click:Connect(function()
                if Debounce == true then
                    Debounce = false
                    script.Parent.Parent.Parent.Parent.Parent.Parent.Sounds.Menu:Play()
                    local LevelTimes = game.ReplicatedStorage.Stored_Values:FindFirstChild(PlayerName)
                    local Level = LevelTimes:FindFirstChild("Level ".. children[i].Name)
                    if Level.Value < 99.999 then
                        game.ReplicatedStorage.Stored_Assets.Player_Assets.Character.Colour.Color3 = Color3.fromRGB(children[i].BackgroundColor3)
                        print(children[i].BackgroundColor3)
                        print("done")
                    end
                    wait(0.1)
                    Debounce = true
                end
            end)
        end
    end
end
0
didyou say Color3.new or just Color3? GamerJanko 50 — 4y
0
game.ReplicatedStorage.Stored_Assets.Player_Assets.Character.Colour.Color3 = Color3.fromRGB(children[i].BackgroundColor3) PastDays 108 — 4y
0
The decal is named color and I'm setting its Color3 PastDays 108 — 4y
0
game.ReplicatedStorage.Stored_Assets.Player_Assets.Character.Colour.Color3 = Color3.new(Color3.fromRGB(children[i].BackgroundColor3)) GamerJanko 50 — 4y
0
That didn't work but after some digging i found that if you times the BackgroundColor3 R,G,B by 255 it will return RGB so that has fixed it. PastDays 108 — 4y

Answer this question