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

Saved a couple values using Data Stores. How do I apply and load them now?

Asked by 5 years ago
Edited 5 years ago

Basically, I created a script that randomizes the Character's Hat, Face, Skin Color and Clothes upon joining. I have saved all those things using Data Stores, but now, how do I load?

I'm aware that only Values can be saved, so that's what has been saved. How in the world do I apply those values back to the Character when loaded?

Some code:

Shirt1 = "rbxassetid://663700531" --boy match fix
Shirt2 = "" --boy match 
Shirt3 = "rbxassetid://591071428" --boy match fix
Shirt4 = "rbxassetid://1117724220" --boy match fix
Shirt5 = "rbxassetid://1953856302" --boy match fix
Shirt6 = "rbxassetid://943047235" --boy single
Shirt7 = "rbxassetid://942999747" --blue tunic single

--male hair
local TreckyHair = 32278814 --boy human
local ChestnutStyle = 212967757 --boy human
local Shaggy = 417457139 --boy human
local StylishBrownHair = 62743701 --boy human
local ChestnutSpikes = 80922374 --boy human
local Beard1 = 158066137 --boy human
local BeautifulHair = 16630147 --boy human

[ A bunch of IDs, these are the IDs that can be potentially randomized onto the Player. ]

local Shirt = Instance.new("Shirt")
local Pants = Instance.new("Pants")

local DataStoreService = game:GetService("DataStoreService")
local CharacterStore = DataStoreService:GetDataStore("CharacterStore")

local CharacterData = {}

CharacterData.ShirtTemplate = player.Character:FindFirstChildOfClass("Shirt").ShirtTemplate
CharacterData.PantsTemplate = player.Character:FindFirstChildOfClass("Pants").PantsTemplate
CharacterData.Face = player.Character.Head.face.Texture
CharacterData.SkinColor = player.Character.Head.BrickColor
CharacterData.Hair = player.Character:FindFirstChildOfClass("Accessory")

CharacterStore:SetAsync(player.UserId,CharacterData)

0
These are small snippets if any additional info is needed just ask. Rebelbeard 2 — 5y

2 answers

Log in to vote
0
Answered by
UPumpkin -34
5 years ago

:GetAsync

0
Yes, GetAsync will return the players I saved. ( to my knowledge ) But, I want the values that were saved to be reapplied back to the character's outfit. Rebelbeard 2 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

If you want to load the datastore

CharacterStore:SetAsync(player.UserId,CharacterData)

You would do

data = CharacterStore:GetAsync(player.UserId)

<3 Hope this helped!

0
Yes, GetAsync will return the players I saved. ( to my knowledge ) But, I want the values that were saved to be reapplied back to the character's outfit. Rebelbeard 2 — 5y

Answer this question