– Code
local DSS = game:GetService(“DataStoreService”):GetDataStore(“SpeedDSS”)
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new(“Folder”, plr)
leaderstats.Name = “” --[[ Change this to the name of your leaderboard name it leaderboard if you want to see the leaderboard, if not set it to a random name, that’s you can remember --]]
local speed = Instance.new(“IntValue”, plr)
speed.Name = “speed”
local jump = Instance.new(“IntValue”, leaderstats)
jump.Name = “jump”
local level = Instance.new(“IntValue”, leaderstats)
level.Name = “level”
local data = DataStoreService:GetAsync(plr.UserId)
if data then
– We know the player has data
speed.Value = data.speed
Jump.Value = data.jump
level.Value = data.level
else
print(“First time playing”)
– Set to default values
speed.Value = 16
jump.Value = 30
level.Value = 0
end
player.CharacterAdded:Connect(function(char)
task.spawn(function()
while wait() do
– Setting walkspeed and jumpower
speed.Value = char:WaitForChild(“Humanoid”).WalkSpeed
jump.Value = Humanoid.JumpPower
end
end)
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
local TableGettingSaved = {}
for i, v in pairs(plr:WaitForChild(“leaderstats”):GetChildren()) do
table.insert(TableGettingSaved, {Name = v.Name, Value = v.Value})
end
DSS:SetAsync(plr.UserId, TableGettingSaved)
end) – I updated the code, try this code instead!