local DataStoreService = game:GetService("DataStoreService")
local playerData = DataStoreService:GetDataStore("PlayerData")
local function onPlayerJoin(player) -- Runs when players join
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local jump = Instance.new("IntValue")
jump.Name = "JumpPowerr"
jump.Parent = leaderstats
local playerUserId = "Player_" .. player.UserId
local data = playerData:GetAsync(playerUserId)
if data then
jump.Value = data
else
jump.Value = 0
end
end
local function onPlayerExit(player)
local success, err = pcall(function()
local playerUserId = "Player" .. player.UserId
playerData:SetAsync(playerUserId, player.leaderstats.jump.Value)
end)
if not success then
warn('Could not save data!')
end
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
game.Players.PlayerRemoving:Connect(onPlayerExit)
it just says in output
“could not save data!”
local script in starterpack:
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local debounce = false
local plrpoints = plr.leaderstats.JumpPowerr
hum:GetPropertyChangedSignal("Jump"):Connect(function()
if debounce then return end
debounce = true
hum.JumpPower = hum.JumpPower + 10
plrpoints.Value = plrpoints.Value + 10
wait(2)
debounce = false
end)
It just says “Could not save data!” because you put that here.
To look at what the issue is just change that string to the “err” thing in the pcall and it should show in the output what the issue is. The “err” will show what the issue is.
local DataStoreService = game:GetService("DataStoreService")
local playerData = DataStoreService:GetDataStore("PlayerData")
local function onPlayerJoin(player) -- Runs when players join
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local jump = Instance.new("IntValue",leaderstats)
jump.Name = "JumpPowerr"
local playerUserId = "Player_" .. player.UserId
local data = playerData:GetAsync(playerUserId)
if data then
jump.Value = data
else
jump.Value = 0
end
end
local function onPlayerExit(player)
local success, err = pcall(function()
local playerUserId = "Player" .. player.UserId
playerData:SetAsync(playerUserId, player.leaderstats:WaitForChild("jump").Value)
end)
if not success then
warn(err)
end
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
game.Players.PlayerRemoving:Connect(onPlayerExit)
Go into studio and press the play button. Go to players, then click on ur player and there should be a folder called leaderstats. Open that folder and show is the insides of it.
Thank you for your feedback!
However, I do think that this would help them a-lot, has there are a-lot of things that they don’t have. (BindToClose, pcalls, etc.)
Yea so that is your issue! Your looking for the value “jump” in the leaderstats folder but the value is called “JumpPowerr” so you should be getting the value of that.
Thats why it says there is nothing called “jump” inside of the folder cuz its not called that it is called “JumpPowerr”