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

Character Customization Datastore not working?

Asked by 5 years ago

I have 2 problems:

  1. There is a problem with my accessories for the custom character "showoff" as I like to call it. It's not appearing on the showoff.

https://gyazo.com/e7e36ef83aa59e473986c0d7876d9a7e

  1. Finishing the customization either giving you the GUI again, after this line of code:

(Under Character Added Function)

local LoadedCAC = CAC:GetAsync(player.UserId)

if not LoadedCAC then
    ReplicatedStorage.GUIS.CUSTOMIZATION:Clone().Parent = player.PlayerGui
end

if LoadedCAC then
    ReplicatedStorage.GUIS.HUD:Clone().Parent = player.PlayerGui -- never runs
end

Or just deleting the GUI like it's intended too, & and not giving you the desired custom character options.

Here is code for the finish button:

script.Parent.FullSize.Side.Finish.MouseButton1Down:Connect(function()
    camera.CameraType = Enum.CameraType.Custom
    camera.CameraSubject = humanoid
    UpdateEvent:FireServer(Hairs[hairCount], Colors[hairColorCount].Value, Shirts[shirtCount], Pantss[pantsCount], Colors[skinColorCount].Value)
    CustomCharacter:Destroy()
    script.Parent:Destroy()
end)

Here is the remote event connection code:

UpdateEvent.OnServerEvent:Connect(function(player, hair, hairColor, shirt, pants, skinColor)
    if player.Character.Humanoid.Health <= 0 then return end

    player:WaitForChild("Hair").Value = hair
    player:WaitForChild("HairColor").Value = hairColor
    player:WaitForChild("SkinColor").Value = skinColor
    player:WaitForChild("Shirt").Value = shirt
    player:WaitForChild("Pants").Value = pants

    save(player)
    player:LoadCharacter()
end)

Where I ATTEMPT to set the desired quallities of custom character in question:

(Under Character Added Function)

for _, v in pairs(character:GetDescendants()) do
            if v:IsA("Accessory") or v:IsA("Shirt") or v:IsA("Pants") or v:IsA("Hat") then
                v:Destroy()
            end
        end

        for _, v in pairs(character:GetDescendants()) do
            if v:IsA("BodyColors") then
                v.HeadColor = player:WaitForChild("SkinColor").Value
                v.LeftArmColor = player:WaitForChild("SkinColor").Value
                v.LeftLegColor = player:WaitForChild("SkinColor").Value
                v.RightArmColor = player:WaitForChild("SkinColor").Value
                v.RightLegColor = player:WaitForChild("SkinColor").Value
                v.TorsoColor = player:WaitForChild("SkinColor").Value
            end
        end

        player:WaitForChild("Hair").Value:Clone().Parent = character
        player:WaitForChild("Shirt").Value:Clone().Parent = character
        player:WaitForChild("Pants").Value:Clone().Parent = character

        character:FindFirstChildOfClass("Accessory"):FindFirstChildOfClass("Part").BrickColor = LoadedCAC.HairColor

Save Function:

local function save(player)
    local Stats = {
        Hair = player:WaitForChild("Hair").Value,
        HairColor = player:WaitForChild("HairColor").Value,
        SkinColor = player:WaitForChild("SkinColor").Value,
        Shirt = player:WaitForChild("Shirt").Value,
        Pants = player:WaitForChild("Pants").Value
    }

    pcall(function() CAC:SetAsync(player.UserId, Stats) end)
end

Thank you for your time.

Answer this question