local myDataStore = DataStoreService:GetDataStore("Data#"..script.DataVersion.Value)
local saving = script["Saving"]
game.Players.PlayerAdded:Connect(function(plr)
local key = plr.UserId.."'s' Data"
local data = myDataStore:GetAsync(key)
print(data)
for _, folder in pairs(script:GetChildren()) do
if folder:IsA("Folder") then
local fc = folder:Clone()
fc.Parent = plr
if saving then
for _, item in pairs(fc:GetChildren()) do
if data then
item.Value = data[item.Name.." "..folder.Name]
else
warn("There is no data!")
end
end
end
end
end
local bar = plr.PlayerGui:WaitForChild("ScreenGui").Levels.EXPbar
local level = plr.PlayerGui:WaitForChild("ScreenGui").Levels.MainPattern.Level
local levelval = plr:WaitForChild("leaderstats").Level.Value
local XPval = plr:WaitForChild("nonleaderstats").XP.Value
level.Text = tostring(levelval)
bar.Text = tostring(XPval).." EXP / "..tostring((levelval*100)+100).." EXP"
local coins = plr.PlayerGui:WaitForChild("ScreenGui").Icons.Coins.TextLabel
local aurumval = plr:WaitForChild("leaderstats").Aurum.Value
coins.Text = tostring(aurumval)
local frame = plr.PlayerGui:WaitForChild("ScreenGui").Dialogue
local but = frame.TextButton
frame.Position = UDim2.new(0.106, 0,1, 0)
local prox = game.Workspace.TutorialNPC.HumanoidRootPart.ProximityPrompt
local option = frame.Option
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120299893"
sound.Parent = game.Workspace
option.Position = UDim2.new(0.937, 0, 1.8, 0)
local cam = game.Workspace.CurrentCamera
local man = game.Workspace.TutorialNPC
local storytext = plr.PlayerGui:WaitForChild("ScreenGui").Storyline.StorylineText
local storyval = plr:WaitForChild("story").story.Value
if storyval == 0 then
storytext.Text = "0"
elseif storyval == 1 then
storytext.Text = "1"
end
print(storyval)
local function appear()
cam.CameraType = Enum.CameraType.Fixed
cam.Focus = man.Head.CFrame
plr.PlayerGui.ScreenGui.Icons.Visible = false
plr.PlayerGui.ScreenGui.ShopFrame.Visible = false
plr.PlayerGui.ScreenGui.Storyline.Visible = false
plr.PlayerGui.ScreenGui.Levels.Visible = false
frame.Position = UDim2.new(0.106, 0,1, 0)
for i = 1, 0.65, -0.05 do
frame.Position = UDim2.new(0.106, 0,i, 0)
wait(0.001)
end
end
local function disappear()
plr.PlayerGui.ScreenGui.Icons.Visible = true
plr.PlayerGui.ScreenGui.Storyline.Visible = true
plr.PlayerGui.ScreenGui.Levels.Visible = true
frame.Position = UDim2.new(0.106, 0,65, 0)
for i = 0.65, 1.2, 0.05 do
frame.Position = UDim2.new(0.106, 0,i, 0)
wait(0.001)
end
cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = plr.Character.Humanoid
end
local function typewrite(text)
local delays = 0.05
for count = 1, #text, 1 do
but.Text = string.sub(text, 1, count)
sound:Play()
wait(delays)
but.MouseButton1Down:Connect(function()
delays = 0.01
end)
but.MouseButton1Up:Connect(function()
delays = 0.05
end)
end
end
local function optionappear(text)
option.Position = UDim2.new(0.937, 0, 1.8, 0)
option.Text = text
for j = 1.8, 0, -0.1 do
option.Position = UDim2.new(0.937, 0, j, 0)
wait(0.001)
end
option.MouseButton1Click:Connect(function()
for K = 0, 1.8, 0.1 do
option.Position = UDim2.new(0.937, 0, K, 0)
wait(0.001)
end
typewrite("a")
wait(1)
typewrite("b")
wait(1)
typewrite("c")
wait(1)
typewrite("d")
wait(1)
typewrite("e")
wait(1)
typewrite("f")
storytext.Text = "f"
wait(1)
disappear()
end)
end
prox.Triggered:Connect(function(player)
if storyval == 0 then
appear()
typewrite("g")
wait(1)
optionappear("h")
storyval = 1
elseif storyval == 1 then
appear()
typewrite("f")
wait(1)
disappear()
end
end)
end)
if saving then
local function create_table(plr)
local player_stats = {}
for _, folder in pairs(script:GetChildren()) do
if folder:IsA("Folder") then
for _, stat in pairs(plr:FindFirstChild(folder.Name):GetChildren()) do
player_stats[stat.Name.." "..folder.Name] = stat.Value
end
end
end
return player_stats
end
game.Players.PlayerRemoving:Connect(function(plr)
local player_stats = create_table(plr)
local succes, err = pcall(function()
local key = plr.UserId.."'s' Data"
myDataStore:SetAsync(key, player_stats)
end)
if succes then
print("Saved Data Correctly!")
else
warn(err)
end
end)
end```
No errors in the output. Aurum saves properly, and I’m not sure about XP and level, but story definitely does not. All of them are Number Values. Everything works properly, and the value changes, but once you leave the server, it is back to 0 again.