Welcome to the Forums!
Join thousands of other Roblox members with a free account.
Create Forum Account

Character Customization Error... again 😅

  • This website was created by Roblox members to replace the official forums (because Roblox shut them down) Join us if you like Roblox!

ElHomburgerGuy

If you won't let yourself fail, you won't improve
Reputation: 5 / 0 / 1
Apr 24, 2019
6,711
24
2,631
113
Anonymous in the USA
Roblox
PieroWasTaking
Hello again,

I manage to make it so it'll change the shirt and pants of both the ClonedCharacter (the dummy that players see in their Menu) and the Player's Character's clothing. But after clicking the buttons a few times the Player's Character's Clothing will no longer change.
1637458006558.png
1637458025157.png

Here's one of the four functions in my LocalScript at the moment for all four functions are basically the same other then what button fires them and whether or not they change the pants or the shirt:
LocalScript:
RightShirtButton.MouseButton1Click:Connect(function()
    if ClonedCharacter ~= nil then
        local FoundShirt = ClonedCharacter:FindFirstChild("Shirt")
        if FoundShirt~= nil then
            FoundShirt.ShirtTemplate = Shirts[1].ShirtTemplate
            PlayerUI.ShirtsFrame.Current.Value = 1
        end
    end
    Services.ReplicatedStorage.Events.UpdateShirt:FireServer(ClonedCharacter.Shirt.ShirtTemplate)
    PlayerUI.ShirtsFrame.Current.Value = PlayerUI.ShirtsFrame.Current.Value + 1
    if PlayerUI.ShirtsFrame.Current.Value > 1 then
        PlayerUI.ShirtsFrame.Current.Value = #Shirts
    end
    ClonedCharacter:WaitForChild("Shirt").ShirtTemplate = Shirts[PlayerUI.ShirtsFrame.Current.Value].ShirtTemplate
    if not ClonedCharacter:FindFirstChild("Shirt") then
        Instance.new("Shirt", ClonedCharacter)
    end
end)

Here's what I have in my script in ServerScriptService:
CharacterCustomization:
--clothing

game.ReplicatedStorage.Events.UpdateShirt.OnServerEvent:Connect(function(player, shirtTemplate)
    local Character = player.Character or player.CharacterAdded:wait()
    if shirtTemplate ~= nil then
        Character.Shirt.ShirtTemplate = shirtTemplate
    end
end)
game.ReplicatedStorage.Events.UpdatePants.OnServerEvent:Connect(function(player, pantsTemplate)
    local Character = player.Character or player.CharacterAdded:wait()
    if pantsTemplate ~= nil then
        Character.Pants.PantsTemplate = pantsTemplate
    end
end)

Only error I get is Attempt to index nil with ShirtTemplate

1637458426885.png

With this line: ClonedCharacter:WaitForChild("Shirt").ShirtTemplate = Shirts[PlayerUI.ShirtsFrame.Current.Value].ShirtTemplate

Any help will be appreciated, thanks!
Post automatically merged:

Update: It no longers gets errors! But now it doesn't change the shirts on the ClonedCharacter No matter which button I choose.

Heres the Current LocalScript:
LocalScript:
--Clothing
local Shirts = Services.ReplicatedStorage:WaitForChild("CustomClothing"):WaitForChild("Shirts"):GetChildren()

Shirt.MouseButton1Click:Connect(function()
    SkinTone:TweenPosition(UDim2.new(1.509, 0,0.759, 0), "Out", "Sine", 1, false)
    ShirtFrame:TweenPosition(UDim2.new(0.741, 0,0.079, 0), "Out", "Sine", 1, false)
    PantFrame:TweenPosition(UDim2.new(1.741, 0,0.177, 0), "Out", "Sine", 1, false)
end)

RightShirtButton.MouseButton1Click:Connect(function()
    if ClonedCharacter ~= nil then
        local FoundShirt = ClonedCharacter:FindFirstChild("Shirt")
        if FoundShirt~= nil then
            FoundShirt.ShirtTemplate = Shirts[1].ShirtTemplate
            PlayerUI.ShirtsFrame.Current.Value = 1
        end
    end
    Services.ReplicatedStorage.Events.UpdateShirt:FireServer(ClonedCharacter.Shirt.ShirtTemplate)
    PlayerUI.ShirtsFrame.Current.Value = PlayerUI.ShirtsFrame.Current.Value + 1
    if PlayerUI.ShirtsFrame.Current.Value > 1 then
        PlayerUI.ShirtsFrame.Current.Value = #Shirts
    end
    ClonedCharacter:WaitForChild("Shirt").ShirtTemplate = Shirts[PlayerUI.ShirtsFrame.Current.Value].ShirtTemplate
    print(ClonedCharacter:WaitForChild("Shirt"))
    if not ClonedCharacter:FindFirstChild("Shirt") then
        Instance.new("Shirt", ClonedCharacter)
    end
end)

LeftShirtButton.MouseButton1Click:Connect(function()
    if ClonedCharacter ~= nil then
        local FoundShirt = ClonedCharacter:FindFirstChild("Shirt")
        if FoundShirt~= nil then
            FoundShirt.ShirtTemplate = Shirts[1].ShirtTemplate
            PlayerUI.ShirtsFrame.Current.Value = 1
        end
    end
    Services.ReplicatedStorage.Events.UpdateShirt:FireServer(ClonedCharacter.Shirt.ShirtTemplate)
    PlayerUI.ShirtsFrame.Current.Value = PlayerUI.ShirtsFrame.Current.Value - 1
    if PlayerUI.ShirtsFrame.Current.Value < 1 then
        PlayerUI.ShirtsFrame.Current.Value = #Shirts
    end
    ClonedCharacter:WaitForChild("Shirt").ShirtTemplate = Shirts[PlayerUI.ShirtsFrame.Current.Value].ShirtTemplate
    print(ClonedCharacter:WaitForChild("Shirt"))
    if not ClonedCharacter:FindFirstChild("Shirt") then
        Instance.new("Shirt", ClonedCharacter)
    end
end)
 

Attachments

  • 1637458410005.png
    1637458410005.png
    99.3 KB · Views: 0
Last edited: