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

keeps say it a part for the folder but it is idk why my data store wont work, how do i fix?

Asked by 4 years ago
local datatsoresevrice = game:GetService("DataStoreService")
 local maydatastore = datatsoresevrice:GetDataStore("mydatastore")

game.Players.PlayerAdded:Connect(function(player)
    local leadstats = Instance.new("Folder")
    leadstats.Name ="leaderstats"
    leadstats.Parent = player
    local money = Instance.new("IntValue")
    money.Name = "Cash"
    money.Parent = leadstats
    local data 
    local done,dailed = pcall(function()
        data = maydatastore:GetAsync(player.Iserid.."-Cash")
        if  done then
            money.Value = data
        else
            print("there is a error")
        end
        end)

end)

game.Players.PlayerRemoving:Connect(function(player)
    maydatastore:SetAsync(player.UserId.."-Cash",player.leaderstats.Value)
end)

1 answer

Log in to vote
0
Answered by
174gb 290 Moderation Voter
4 years ago
Edited 4 years ago

1° - In line 24, you put "leaderstats.Value" and how leaderstats is a folder he don't have a value. 2° - In Line, 13 you put "player.Iserid" and it would be "player.UserId". 3° - The data store script must be would this:

-- I tested and it works fine

local datatsoresevrice = game:GetService("DataStoreService")
 local maydatastore = datatsoresevrice:GetDataStore("mydatastore")

game.Players.PlayerAdded:Connect(function(player)
    local leadstats = Instance.new("Folder")
    leadstats.Name ="leaderstats"
    leadstats.Parent = player
    local money = Instance.new("IntValue")
    money.Name = "Cash"
    money.Parent = leadstats
    local data
        data = maydatastore:GetAsync(player.UserId.."-Cash")
         money.Value = data
end)


game.Players.PlayerRemoving:Connect(function(player)
 maydatastore:SetAsync(player.UserId.."-Cash",player.leaderstats.Cash.Value)
end)

Ad

Answer this question