hi , my Melee and my defend keep Setting to zero,
game.Players.PlayerAdded:Connect(function(player)
if ServerStorage:FindFirstChild(".playerproperty") then
local PlayerProperty = ServerStorage:WaitForChild(".playerproperty")
local Folder = Instance.new("Folder")
Folder.Name = player.Name
Folder.Parent = PlayerProperty
local Stats = Instance.new("Folder")
Stats.Name = "Stats"
Stats.Parent = Folder
local Melee =Instance.new("IntValue")
Melee.Name = "Melee"
Melee.Parent = Stats
local Stamina = Instance.new("IntValue")
Stamina.Name = "Stamina"
Stamina.Parent = Stats
Stamina.Value = 100 * Melee.Value
local Def = Instance.new("IntValue")
Def.Name = "Defend"
Def.Parent = Stats
local Agi = Instance.new("IntValue")
Agi.Name = "Agility"
Agi.Parent =Stats
local Df = Instance.new("StringValue")
Df.Name = "DevilFruit"
Df.Parent = Stats
Df.Value = 1
local HakiObtain = Instance.new("BoolValue")
HakiObtain.Name = "HakiObtained"
HakiObtain.Value = false
HakiObtain.Parent = Stats
local Point = Instance.new("IntValue")
Point.Name = "Point"
Point.Parent = Stats
Point.Value = 5
local Cash = Instance.new("IntValue")
Cash.Name = "Cash"
Cash.Parent = Stats
Cash.Value = 100
local Sword = Instance.new("IntValue")
Sword.Name = "Sword"
Sword.Value = 1
Sword.Parent = Stats
Melee.Value = 1
Def.Value = 1
Agi.Value = 100 * Melee.Value
local Code = player.UserId
local Data
local Succes, bugs = pcall(function()
Data =DataStore:GetAsync(Code)
end)
if Succes then
Melee.Value = Data.Melee
Def.Value = Data.Def
Df.Value = Data.Df
HakiObtain.Value = Data.HakiOb
Point.Value = Data.Point
Cash.Value = Data.Cash
Sword.Value = Data.Sword
else
error(bugs)
end
end
end)
function save(code,data)
local succes ,err = pcall(function()
DataStore:SetAsync(code,data)
end)
end
game.Players.PlayerRemoving:Connect(function(plr)
local Code = plr.UserId
local Data = {
Melee = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.Melee.Value;
Sword = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.Sword.Value;
Def = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.Defend.Value;
Df = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.DevilFruit.Value;
HakiOb = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.HakiObtained.Value;
Point = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.Point.Value;
Cash = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.Cash.Value;
}
save(Code,Data)
end)
game:BindToClose(function()
for i,v in pairs(ServerStorage:WaitForChild(".playerproperty"):GetChildren()) do
for i, plr in pairs(game:GetService("Players"):GetChildren()) do
local Code = plr.UserId
local Player_Data = v[plr.Name].Stats
local Data = {
Melee = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.Melee.Value;
Sword = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.Sword.Value;
Def = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.Defend.Value;
Df = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.DevilFruit.Value;
HakiOb = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.HakiObtained.Value;
Point = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.Point.Value;
Cash = ServerStorage:WaitForChild(".playerproperty")[plr.Name].Stats.Cash.Value;
}
save(Code,Data)
end
end
end)