New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
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 3 months 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
sO_Ov 150
3 months ago
Edited 3 months 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