Hey, i am new to httpsservice and i want to learn, as of now i am trying to save my avatar’s appearance and load it again when i join, but for some reason when i decode it, it returns a table and not a string. i may be dumb and do one real clear rookie mistake
_G.CanChangeAvatar = true
local HttpService = game:GetService("HttpService")
local AvatarStore = game:GetService("DataStoreService"):GetDataStore("AvatarStore")
game:GetService("Players").PlayerAdded:Connect(function(plr)
if AvatarStore:GetAsync(plr.UserId.. "HumanoidSave") then
print("it has saved")
task.wait(5)
local humjson = AvatarStore:GetAsync(tostring(plr.UserId) .. "HumanoidSave")
print("turning json into thing")
local humanoidtable = HttpService:JSONDecode(humjson)
print(humanoidtable)
local humDescription = Instance.new("HumanoidDescription")
for property, value in pairs(humanoidtable) do
humDescription[property] = value
end
workspace.Rig.Humanoid:ApplyDescription(humDescription)
print("ah dammnit")
return
end
task.wait(15)
if _G.CanChangeAvatar then
local appearance = game:GetService("Players"):GetHumanoidDescriptionFromUserId(plr.UserId)
local HumDescTable = {
BodyTypeScale = appearance.BodyTypeScale,
DepthScale = appearance.DepthScale
}
local humanoidDescriptionJSON = HttpService:JSONEncode(HumDescTable)
print(humanoidDescriptionJSON)
AvatarStore:SetAsync(tostring(plr.UserId) .. "HumanoidSave", humanoidDescriptionJSON)
workspace:WaitForChild("Rig"):FindFirstChildWhichIsA("Humanoid"):ApplyDescription(appearance)
local Animation = Instance.new("Animation", workspace:FindFirstChild("Rig"))
Animation.Name = "DanceAnim"
Animation.AnimationId = "rbxassetid://18711469609"
local loadanim = workspace.Rig.Humanoid:LoadAnimation(Animation)
loadanim:Play()
end
end)