The datastore saves values changed from the ServerScriptService but not starter gui. Filtering enabled is on and I am trying to access the datastore through StarterGui. The StarterGui script is a local script. Do I need to use a remote event? If so, how?
StarterGui Script:
local bio = game.Players.LocalPlayer.CharacterBio
bio.Gender.Value = "Female"
Datastore:
local DSService = game:GetService('DataStoreService'):GetDataStore('Test')
game.Players.PlayerAdded:connect(function(plr)
local uniquekey = 'id'..plr.userId
local charbio = Instance.new('Folder',plr)
charbio.Name = "CharacterBio"
local new = Instance.new('StringValue',charbio)
new.Name = "New"
local gender = Instance.new('StringValue',charbio)
gender.Name = "Gender"
local hair = Instance.new('StringValue',charbio)
hair.Name = "Hair"
local hairc = Instance.new('StringValue',charbio)
hairc.Name = "HairC"
local shirt = Instance.new('IntValue',charbio)
shirt.Name = "Shirt"
local pants = Instance.new('IntValue',charbio)
pants.Name = "Pants"
local dress = Instance.new('StringValue',charbio)
dress.Name = "Dress"
local mask = Instance.new('StringValue',charbio)
mask.Name = "Mask"
local gloves = Instance.new('IntValue',charbio)
gloves.Name = "Gloves"
local elite = Instance.new('StringValue',charbio)
elite.Name = "Elite"
local class = Instance.new('StringValue',charbio)
class.Name = "Class"
local scar = Instance.new('IntValue',charbio)
scar.Name = "Scar"
local skin = Instance.new('StringValue',charbio)
skin.Name = "Skin"
local gold = Instance.new('IntValue',charbio)
gold.Name = "Gold"
local level = Instance.new('IntValue',charbio)
level.Name = "Level"
local exp = Instance.new('IntValue',charbio)
exp.Name = "Experience"
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
for i,v in pairs(charbio:GetChildren()) do
v.Value = GetSaved[i]
end
else
local NumbersForSaving = {new.Value,gender.Value,hair.Value,hairc.Value,shirt.Value,pants.Value,dress.Value,mask.Value,gloves.Value,elite.Value,class.Value,scar.Value,skin.Value,gold.Value,level.Value,exp.Value}
DSService:SetAsync(uniquekey,NumbersForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id'..plr.userId
local bio = plr.CharacterBio
local values = {bio.New.Value,bio.Gender.Value,bio.Hair.Value,bio.HairC.Value,bio.Shirt.Value,bio.Pants.Value,bio.Dress.Value,bio.Mask.Value,bio.Gloves.Value,bio.Elite.Value,bio.Class.Value,bio.Scar.Value,bio.Skin.Value,bio.Gold.Value,bio.Level.Value,bio.Experience.Value}
DSService:SetAsync(uniquekey,values)
end)
