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

my datastore script dont save any data???

Asked by 4 years ago
local DataStoreService = game:GetService("DataStoreService")
local MyDataStore = DataStoreService:GetDataStore("HaveBreathing")

game.Players.PlayerAdded:Connect(function(player)
    local havebre = Instance.new("Folder")
    havebre.Name = "havebre"
    havebre.Parent = player

    local HaveBreathing = Instance.new("IntValue")
    HaveBreathing.Name = "HaveBreathing"
    HaveBreathing.Parent = havebre
end)

game.Players.PlayerRemoving:Connect(function(player)
    MyDataStore:SetAsync(player.UserId, player.havebre.HaveBreathing.Value)
end)

dont save why

2 answers

Log in to vote
0
Answered by 4 years ago

It IS Saving it, you are just not assigning the value of the "IntValue".

HaveBreathing.Value = MyDataStore:GetAsync(player.UserId)
Ad
Log in to vote
-1
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago

This should work also, you can put whatever you need inside the code

local sampleDataStore = game:GetService("DataStoreService"):GetDataStore("MyDataStore")

game.Players.PlayerRemoving:Connect(function(player)
    local playerKey = "Player_" .. player.UserId

    local success, val = pcall(function()
        return sampleDataStore:RemoveAsync(playerKey)
    end)

    if success then
        print(val)
    end
end)

Answer this question