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

Save BodyWidthScale, BodyHeightScale, and BodyDepthScale?

Asked by 6 years ago

Im trying to save the Humanoid children BodyWidthScale, BodyHeightScale, and BodyDepthScale. I got a datastore script used to save leaderstats and changed it up. Now it doesn't seem to work. What I want is those 3 values to save and be reloaded back to the players character every time they reset or leave the game and join back. The strange thing is that I'm not getting any errors, but at the same time, the values dont save and reload what so ever

script.Parent= nil

local minute= (10)

function save(player)
    local StatToSave = player.Chracter.Humanoid
    ---------
    local datastore = game:GetService('DataStoreService'):GetDataStore(player.Name..'Stats')
    local statstorage = StatToSave:GetChildren()
        for i =  1, #statstorage do
            datastore:SetAsync(statstorage[i].Name, statstorage[i].Value)
        end
print(player.Name..' size AUTOSAVED')
end


game.Players.LocalPlayer.CharacterAdded:connect(function()
    local player = game.Players.LocalPlayer
    local StatToSave = player.Chracter.Humanoid:GetChildren()
local led= script:findFirstChild(StatToSave)
repeat wait() until led~= nil
local BWS = player.Character:findFirstChild("Humanoid").BodyWidthScale
BWS:Delete()

local BDS = player.Character:findFirstChild("Humanoid").BodyDepthScale
BDS:Delete()

local BHS = player.Character:findFirstChild("Humanoid").BodyHeightScale
BHS:Delete()

led:Clone().Parent= player.Character.Humanoid
    local datastore = game:GetService('DataStoreService'):GetDataStore(player.Name..'Stats')
        player.Character:FindFirstChild("Humanoid"):GetChildren()   wait()
        local stats = player.Character:FindFirstChild("Humanoid"):GetChildren()
        for i = 1, #stats do            
            stats[i].Value = datastore:GetAsync(stats[i].Name)
            print("Size LOADED")
        end
if player.Name:match("Guest") then
print(player.Name..' has joined')
else end
        while game.Players:findFirstChild(player.Name) do
            save(player)
            wait(minute)
        end
end)

game.Players.PlayerRemoving:connect(function(player)
    local datastore = game:GetService('DataStoreService'):GetDataStore(player.Name..'Stats')
    local statstorage = player.Character:findFirstChild("Humanoid"):GetChildren()
        for i =  1, #statstorage do
            datastore:SetAsync(statstorage[i].Name, statstorage[i].Value)
        end
            print(player.Name..' Size saved succesfully! ') 
end)
0
If you indent, indent correctly. hiimgoodpack 2009 — 6y
0
i wasnt the one who made the script, like i said, i messed with it taunter165 30 — 6y

Answer this question