Hello, i am making a dress up system. I’ve already done most of it, i only need to save the current outfit right now. I only know how to save values but not a whole table.
My code doesnt have a pre-made table with value names already set in, it creates its childs:
*i know its kinda non-sense: playerCurrentOutfit[child.Name] = child.Name but that was the only solution i found for adding the child.
local currentOutfit = dataStore:GetDataStore("currentOutfit")
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEventsFolder = replicatedStorage.remoteEvents
local communicatorRemoteEvent = remoteEventsFolder:FindFirstChild("communicationResetRemoteEvent")
local currentOutfitTable = {}
game.Players.PlayerAdded:Connect(function(player)
local playerCurrentOutfit = {}
currentOutfitTable[player.UserId] = playerCurrentOutfit
player.CharacterAdded:Connect(function(newCharacter)
newCharacter.ChildAdded:Connect(function(child) --adds child
if child:IsA("Model") then
playerCurrentOutfit[child.Name] = child.Name
end
end)
newCharacter.ChildRemoved:Connect(function(child) --removes child
if child:IsA("Model") then
playerCurrentOutfit[child.Name] = nil
end
end)
if playerCurrentOutfit ~= nil then --when reset
for _, i in pairs(playerCurrentOutfit) do
local itemString = playerCurrentOutfit[i]
local itemInRP = replicatedStorage:FindFirstChild(itemString, true)
if itemInRP.Parent.Name == "heelsContainer" then
communicatorRemoteEvent:FireClient(player, itemString, "heelsRemoteEvent")
elseif itemInRP.Parent.Name == "dressContainer" then
communicatorRemoteEvent:FireClient(player, itemString, "dressRemoteEvent")
elseif itemInRP.Parent.Name == "hatsContainer" then
communicatorRemoteEvent:FireClient(player, itemString, "hatRemoteEvent")
elseif itemInRP.Parent.Name == "haloContainer" then
communicatorRemoteEvent:FireClient(player, itemString, "haloRemoteEvent")
elseif itemInRP.Parent.Name == "hairContainer" then
communicatorRemoteEvent:FireClient(player, itemString, "hairRemoteEvent")
elseif itemInRP.Parent.Name == "corsetsContainer" then
communicatorRemoteEvent:FireClient(player, itemString, "corsetsRemoteEvent")
elseif itemInRP.Parent.Name == "wingsContainer" then
communicatorRemoteEvent:FireClient(player, itemString, "wingsRemoteEvent")
elseif itemInRP.Parent.Name == "tailsContainer" then
communicatorRemoteEvent:FireClient(player, itemString, "tailsRemoteEvent")
end
end
end
end)
end)
i know this is kind off asking for the whole script but, can anyone help me out? I tried to look-up past posts on devforum, but none matches my case
