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

Targeting StarterCharacter part(s), and changing properties?

Asked by 3 years ago

Hi there! I've been working on a sort of digital clock that the player wears on their chest. I've managed to get this to work when it's not on the character. I put the script and NumberValue in StarterCharacterScripts.

Basically what I need is for this to target the individual parts (A-G) of the custom character model, so that the + and - buttons will change the displayed value. I've only got super basic lua knowledge (which is probably obvious looking at the code), and I can't seem to figure out what to do, even after looking online, so any pointers would be very much appreciated!

local Number = script.Parent.NumberValue
local A = script.Parent.A
local B = script.Parent.B
local C = script.Parent.C
local D = script.Parent.D
local E = script.Parent.E
local F = script.Parent.F
local G = script.Parent.G



workspace.ButtonMinus.ClickDetector.MouseClick:Connect(function()
    Number.Value -= 1
end)


workspace.ButtonPlus.ClickDetector.MouseClick:Connect(function()
    Number.Value += 1
end)





while true do
    wait(0.1)
    if Number.Value == 1 then
        A.BrickColor = BrickColor.new("Medium stone grey")
        A.Material = Enum.Material.Metal
        B.BrickColor = BrickColor.new("Medium stone grey")
        B.Material = Enum.Material.Metal
        C.BrickColor = BrickColor.new("Persimmon")
        C.Material = Enum.Material.Neon
        D.BrickColor = BrickColor.new("Medium stone grey")
        D.Material = Enum.Material.Metal
        E.BrickColor = BrickColor.new("Persimmon")
        E.Material = Enum.Material.Neon
        F.BrickColor = BrickColor.new("Medium stone grey")
        F.Material = Enum.Material.Metal
        G.BrickColor = BrickColor.new("Medium stone grey")
        G.Material = Enum.Material.Metal
    else if Number.Value == 2 then
            A.BrickColor = BrickColor.new("Medium stone grey")
            A.Material = Enum.Material.Metal
            B.BrickColor = BrickColor.new("Persimmon")
            B.Material = Enum.Material.Neon
            C.BrickColor = BrickColor.new("Persimmon")
            C.Material = Enum.Material.Neon
            D.BrickColor = BrickColor.new("Persimmon")
            D.Material = Enum.Material.Neon
            E.BrickColor = BrickColor.new("Medium stone grey")
            E.Material = Enum.Material.Metal
            F.BrickColor = BrickColor.new("Persimmon")
            F.Material = Enum.Material.Neon
            G.BrickColor = BrickColor.new("Persimmon")
            G.Material = Enum.Material.Neon
        else if Number.Value == 3 then
                A.BrickColor = BrickColor.new("Medium stone grey")
                A.Material = Enum.Material.Metal
                B.BrickColor = BrickColor.new("Persimmon")
                B.Material = Enum.Material.Neon
                C.BrickColor = BrickColor.new("Persimmon")
                C.Material = Enum.Material.Neon
                D.BrickColor = BrickColor.new("Persimmon")
                D.Material = Enum.Material.Neon
                E.BrickColor = BrickColor.new("Persimmon")
                E.Material = Enum.Material.Neon
                F.BrickColor = BrickColor.new("Persimmon")
                F.Material = Enum.Material.Neon
                G.BrickColor = BrickColor.new("Medium stone grey")
                G.Material = Enum.Material.Metal
            else if Number.Value == 4 then
                    A.BrickColor = BrickColor.new("Persimmon")
                    A.Material = Enum.Material.Neon
                    B.BrickColor = BrickColor.new("Medium stone grey")
                    B.Material = Enum.Material.Metal
                    C.BrickColor = BrickColor.new("Persimmon")
                    C.Material = Enum.Material.Neon
                    D.BrickColor = BrickColor.new("Persimmon")
                    D.Material = Enum.Material.Neon
                    E.BrickColor = BrickColor.new("Persimmon")
                    E.Material = Enum.Material.Neon
                    F.BrickColor = BrickColor.new("Medium stone grey")
                    F.Material = Enum.Material.Metal
                    G.BrickColor = BrickColor.new("Medium stone grey")
                    G.Material = Enum.Material.Metal
                else if Number.Value == 5 then
                        A.BrickColor = BrickColor.new("Persimmon")
                        A.Material = Enum.Material.Neon
                        B.BrickColor = BrickColor.new("Persimmon")
                        B.Material = Enum.Material.Neon
                        C.BrickColor = BrickColor.new("Medium stone grey")
                        C.Material = Enum.Material.Metal
                        D.BrickColor = BrickColor.new("Persimmon")
                        D.Material = Enum.Material.Neon
                        E.BrickColor = BrickColor.new("Persimmon")
                        E.Material = Enum.Material.Neon
                        F.BrickColor = BrickColor.new("Persimmon")
                        F.Material = Enum.Material.Neon
                        G.BrickColor = BrickColor.new("Medium stone grey")
                        G.Material = Enum.Material.Metal
                    else if Number.Value == 6 then
                            A.BrickColor = BrickColor.new("Persimmon")
                            A.Material = Enum.Material.Neon
                            B.BrickColor = BrickColor.new("Persimmon")
                            B.Material = Enum.Material.Neon
                            C.BrickColor = BrickColor.new("Medium stone grey")
                            C.Material = Enum.Material.Metal
                            D.BrickColor = BrickColor.new("Persimmon")
                            D.Material = Enum.Material.Neon
                            E.BrickColor = BrickColor.new("Persimmon")
                            E.Material = Enum.Material.Neon
                            F.BrickColor = BrickColor.new("Persimmon")
                            F.Material = Enum.Material.Neon
                            G.BrickColor = BrickColor.new("Persimmon")
                            G.Material = Enum.Material.Neon
                        else if Number.Value == 7 then
                                A.BrickColor = BrickColor.new("Medium stone grey")
                                A.Material = Enum.Material.Metal
                                B.BrickColor = BrickColor.new("Persimmon")
                                B.Material = Enum.Material.Neon
                                C.BrickColor = BrickColor.new("Persimmon")
                                C.Material = Enum.Material.Neon
                                D.BrickColor = BrickColor.new("Medium stone grey")
                                D.Material = Enum.Material.Metal
                                E.BrickColor = BrickColor.new("Persimmon")
                                E.Material = Enum.Material.Neon
                                F.BrickColor = BrickColor.new("Medium stone grey")
                                F.Material = Enum.Material.Metal
                                G.BrickColor = BrickColor.new("Medium stone grey")
                                G.Material = Enum.Material.Metal
                            else if Number.Value == 8 then
                                    A.BrickColor = BrickColor.new("Persimmon")
                                    A.Material = Enum.Material.Neon
                                    B.BrickColor = BrickColor.new("Persimmon")
                                    B.Material = Enum.Material.Neon
                                    C.BrickColor = BrickColor.new("Persimmon")
                                    C.Material = Enum.Material.Neon
                                    D.BrickColor = BrickColor.new("Persimmon")
                                    D.Material = Enum.Material.Neon
                                    E.BrickColor = BrickColor.new("Persimmon")
                                    E.Material = Enum.Material.Neon
                                    F.BrickColor = BrickColor.new("Persimmon")
                                    F.Material = Enum.Material.Neon
                                    G.BrickColor = BrickColor.new("Persimmon")
                                    G.Material = Enum.Material.Neon
                                else if Number.Value > 8 then
                                        A.BrickColor = BrickColor.new("Persimmon")
                                        A.Material = Enum.Material.Neon
                                        B.BrickColor = BrickColor.new("Persimmon")
                                        B.Material = Enum.Material.Neon
                                        C.BrickColor = BrickColor.new("Persimmon")
                                        C.Material = Enum.Material.Neon
                                        D.BrickColor = BrickColor.new("Persimmon")
                                        D.Material = Enum.Material.Neon
                                        E.BrickColor = BrickColor.new("Persimmon")
                                        E.Material = Enum.Material.Neon
                                        F.BrickColor = BrickColor.new("Persimmon")
                                        F.Material = Enum.Material.Neon
                                        G.BrickColor = BrickColor.new("Medium stone grey")
                                        G.Material = Enum.Material.Metal
                                    else if Number.Value < 1 then
                                            A.BrickColor = BrickColor.new("Persimmon")
                                            A.Material = Enum.Material.Neon
                                            B.BrickColor = BrickColor.new("Persimmon")
                                            B.Material = Enum.Material.Neon
                                            C.BrickColor = BrickColor.new("Persimmon")
                                            C.Material = Enum.Material.Neon
                                            D.BrickColor = BrickColor.new("Medium stone grey")
                                            D.Material = Enum.Material.Metal
                                            E.BrickColor = BrickColor.new("Persimmon")
                                            E.Material = Enum.Material.Neon
                                            F.BrickColor = BrickColor.new("Persimmon")
                                            F.Material = Enum.Material.Neon
                                            G.BrickColor = BrickColor.new("Persimmon")
                                            G.Material = Enum.Material.Neon
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end

Answer this question