so, i’m making RPG game, I did leaderstats with data store,i watched every single tutorial on YouTube but none is working, can someone help me with this? (yes, I enabled Studio AIP services, here is script:
leaderstats:
local dataStore = game:GetService(“DataStoreService”)
local myDataStore = dataStore:GetDataStore(“MyDataStore”)
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Wind = Instance.new("IntValue", leaderstats)
Wind.Name = "Winds"
local Level = Instance.new("IntValue", leaderstats)
Level.Name = "Level"
Level.Value = 1
local Exp = Instance.new("NumberValue",player)
Exp.Name = "Exp"
Exp.Value = 0
local RequiredExp = Instance.new("NumberValue", player)
RequiredExp.Name = "RequiredExp"
RequiredExp.Value = Level.Value * 100
Exp.Changed:Connect(function(Changed)
if Exp.Value >= RequiredExp.Value then
Exp.Value = 0
Level.Value += 1
RequiredExp.Value = Level.Value * 100
end
end)
end)
datastore script:
local myDataStore = game:GetService(“DataStoreService”):GetDataStore(“MyDataStore”)
game.Players.PlayerAdded:Connect(function(player)
wait()
local playerId = “Id_”…player.UserId
local data1 = {player.leaderstats.Winds.Value,}
local data2 = {player.leaderstats.Exp.Value,}
local data3 = {player.leaderstats.Level.Value,}
local data4 = {player.leaderstats.RequiredEXp.Value,}
local Save = myDataStore:GetAsync(playerId)
if Save then
data1.Value = Save
else
local current = {
data1.Value,
data2.Value,
data3.Value,
data4.Value}
myDataStore:GetAsync(playerId, current)
end
end)
local myDataStore = game:GetService(“DataStoreService”):GetDataStore(“MyDataStore”)
game.Players.PlayerAdded:Connect(function(player)
wait()
local playerId = “Id_”…player.UserId
local data1 = {player.leaderstats.Winds.Value,}
local data2 = {player.leaderstats.Exp.Value,}
local data3 = {player.leaderstats.Level.Value,}
local data4 = {player.leaderstats.RequiredEXp.Value,}
local Save = myDataStore:GetAsync(playerId)
if Save then
data1.Value = Save
else
local current = {
data1.Value,
data2.Value,
data3.Value,
data4.Value}
myDataStore:GetAsync(playerId, current)
end
end)
local myDataStore = game:GetService(“DataStoreService”):GetDataStore(“MyDataStore”)
game.Players.PlayerAdded:Connect(function(player)
wait()
local playerId = "id_"..player.UserId
local data1 = player.leaderstats.Winds.Value
local data2 = player.leaderstats.Exp.Value
local data3 = player.leaderstats.Level.Value
local data4 = player.leaderstats.RequiredEXp.Value
local Save = myDataStore:GetAsync(playerId)
if Save then
data1.Value = Save[1]
data2.Value = Save[2]
data3.Value = Save[3]
data4.Value = Save[4]
else
local current = {
data1.Value,
data2.Value,
data3.Value,
data4.Value}
end
end)
game.Players.PlayerRemoving:Connect(function(player)
myDataStore:SetAsync("id_"..player.UserId,{
player.leaderstats.Winds.Value,
player.leaderstats.Level.Value,
player.leaderstats.Exp.Value,
player.leaderstats.RequiredExp.Value})
end)