Помогите не работает код

Floppa_dev

Member
22 Сен 2024
9
9
3
Ошибка
leaderstats is not a valid member of Player "101Vova10" - Server - Leaderstats:19
Код
local DataStore = game:GetService("DataStoreService")
local CashData = DataStore:GetDataStore("CashStats")
local Value = 0

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

local cash= Instance.new("IntValue")
cash.Name = ("Cash") --Cash Value
cash.Parent = leaderstats
cash.Value = 0 -- Starter Value
cash.Value = CashData:GetAsync(player.UserId) or Value
CashData:SetAsync(player.UserId, cash.Value)

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

end)
 

Commander

Бесмертный
Команда форума
Администрация
21 Сен 2024
3
8
1 002
вроде этот код должен работать
Код:
local DataStore = game:GetService("DataStoreService")
local CashData = DataStore:GetDataStore("CashStats")
local Value = 0

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

    local cash= Instance.new("IntValue")
    cash.Name = ("Cash") --Cash Value
    cash.Parent = leaderstats
    cash.Value = 0 -- Starter Value
    cash.Value = CashData:GetAsync(player.UserId) or Value
    CashData:SetAsync(player.UserId, cash.Value)
end)

game.Players.PlayerRemoving:Connect(function(player)
    CashData:SetAsync(player.UserId, player.leaderstats.Cash.Value)
end)
ты сделал game.Players.PlayerRemoving в game.Players.PlayerAdded Ивенте
 
  • Лайк
Реакции: Hichimiro и Nicon

Floppa_dev

Member
22 Сен 2024
9
9
3
вроде этот код должен работать
Код:
local DataStore = game:GetService("DataStoreService")
local CashData = DataStore:GetDataStore("CashStats")
local Value = 0

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

    local cash= Instance.new("IntValue")
    cash.Name = ("Cash") --Cash Value
    cash.Parent = leaderstats
    cash.Value = 0 -- Starter Value
    cash.Value = CashData:GetAsync(player.UserId) or Value
    CashData:SetAsync(player.UserId, cash.Value)
end)

game.Players.PlayerRemoving:Connect(function(player)
    CashData:SetAsync(player.UserId, player.leaderstats.Cash.Value)
end)
ты сделал game.Players.PlayerRemoving в game.Players.PlayerAdded Ивенте
спасибо