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

Recolour UI turns things default grey ?

Asked by 3 years ago

i'm trying to make a UI that changes the Brick Colour of a part. I've gotten the part(s) to change colour but it only turns the affected part(s) the default grey colour.

GUI code :

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
    character = player.CharacterAdded:wait()
end
script.Parent.MouseButton1Click:Connect(function(plr)
    local c = script.Parent.Part.BrickColor
    local C3 = c.Name
    character.PlayerInfo.ColourSel.Value = C3
    wait(0.30)
    ReplicatedStorage.Recolour:FireServer()
end)

this code changes the value of a string tag found in the character to the name of the desired brick colour (which is gotten from a part found in the colour button) and then fires the recolour event to update the colour using ServerScriptService.

ServerScriptService code:

game.ReplicatedStorage.Recolour.OnServerEvent:Connect(function(plr)
    local char = plr.Character 
    local LAI1 = char.PlayerInfo.LastAppliedItem1.value
    local ColourType = char.PlayerInfo.ColourType.value
    local ColourSel = char.PlayerInfo.ColourSel.value
    if ColourType ~= ('2') then 
        if LAI1 ~= ('null') then
            for index, D in next, char[LAI1]:GetChildren() do
                if D.Name == '1' then
                    D.BrickColor = BrickColor.new(ColourSel)
                end
            end
        end
    end
    print('Recolour Fired !')
end)

this code finds all the parts named '1' and applies the Brick Colour name from the ColourSel String value

Answer this question