Brief Summary
I'm working on a data store for saved outfits after the player customizes their character. Once they select the article of clothing, it saves the shirt/pants ID in a StringValue inside the Player. When the player returns, the shirt they previously saved loads properly, but the pants do not.
Scripts
Here's a snippet of the script from the button they press to select the shirt/pants (basically same for both):
local shirt = game.ReplicatedStorage.Customizer.Male.Shirt.GoldTee.Value game.Players.LocalPlayer.clothes.Shirt.Value = "http://www.roblox.com/asset/?id="..shirt
The script above seems to work fine, but I figured it might help to get a better understanding.
Here's a snippet of the script designed for loading the outfit:
local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."outfit") player:WaitForChild("clothes") wait(1) local stats = player:FindFirstChild("clothes"):GetChildren() for i = 1, #stats do stats[i].Value = datastore:GetAsync(stats[i].Name) or "was nil" -- I imagine this is where problem lies print("stat "..i.." has been found")
Snippet of script for saving the outfit:
game.Players.PlayerRemoving:connect(function(player) local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."outfit") local statstorage = player:FindFirstChild("clothes"):GetChildren() for i = 1, #statstorage do datastore:SetAsync(statstorage[i].Name, statstorage[i].Value) print("saved "..i) end end)
Extra Information
The "clothes" is the name of the IntValue that contains the Shirt & Pants StringValues. I added "was nil" since it's a StringValue and now the Pants.Value reads, "was nil". I'm sure I am overlooking something simple/doing something stupid, but I'm not good with DataStores. If you could throw out some ideas or point out my mistake, I'd greatly appreciate it!