This script I've created doesn't save, but has no errors. Please help?
So, here's the script:
001 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
002 | local DS = game:GetService( "DataStoreService" ):GetDataStore( "Statsandstuff" ) |
005 | game.Players.PlayerAdded:Connect( function (plr) |
007 | repeat wait() until player.Character |
009 | local hitbox = Instance.new( "Part" ) |
010 | local weld = Instance.new( "Weld" ,hitbox) |
011 | hitbox.Parent = player.Character |
012 | hitbox.Name = "PlayerHitBox" |
013 | hitbox.Size = Vector 3. new( 3.85 , 5.74 , 1.19 ) |
014 | hitbox.Position = Vector 3. new(player.Character.UpperTorso.Position.X,player.Character.UpperTorso.Position.Y - 2 ,player.Character.UpperTorso.Position.Z) |
015 | hitbox.Transparency = 1 |
016 | hitbox.CanCollide = false |
018 | weld.Part 1 = player.Character.HumanoidRootPart |
020 | local folder = Instance.new( "Folder" ) |
021 | folder.Name = player.Name |
022 | folder.Parent = ReplicatedStorage |
024 | local folder 2 = Instance.new( "Folder" ) |
025 | folder 2. Name = player.Name |
026 | folder 2. Parent = game:GetService( "ServerScriptService" ) |
028 | local vars = Instance.new( "Folder" ) |
032 | local Int = Instance.new( "NumberValue" ) |
034 | Int.Name = "Intelligence" |
036 | local Lev = Instance.new( "NumberValue" ) |
040 | local Points = Instance.new( "NumberValue" ) |
042 | Points.Name = "Points" |
044 | local Quirk = Instance.new( "StringValue" ) |
048 | local QuirkD = Instance.new( "NumberValue" ) |
050 | QuirkD.Name = "QuirkDevelopment" |
052 | local Stam = Instance.new( "NumberValue" ) |
054 | Stam.Name = "Stamina" |
056 | local Str = Instance.new( "NumberValue" ) |
058 | Str.Name = "Strength" |
060 | local XP = Instance.new( "NumberValue" ) |
064 | local XPTL = Instance.new( "NumberValue" ) |
066 | XPTL.Name = "XPtolevel" |
068 | local savedstuff = DS:GetAsync(plr.userId) |
070 | for i,v in pairs (savedstuff) do |
072 | ReplicatedStorage [ plr.Name ] .Vars:FindFirstChild(savedstuff [ i- 1 ] ).Value = v |
080 | Quirk.Value = "Quirkless" |
090 | local function savestuff(plr) |
092 | for i,v in pairs (ReplicatedStorage [ plr.Name ] .Vars:GetChildren()) do |
093 | saveddata [ #saveddata + 1 ] = v.Name |
094 | saveddata [ #saveddata + 1 ] = v.Value |
096 | DS:SetAsync(plr.userId, saveddata) |
099 | game.Players.PlayerRemoving:Connect( function (plr) |
I get no errors whatsoever, but it won't save. Please help!