Hello, I’ve been having some difficulty as I find understanding datastores quite difficult.
I would really appreciate if someone could help me, I am trying to make a script which whenever you leave the game it saves you JumpPower and it saves the stats from my leaderboard. I’d appreciate if someone could help me create this script.
Thank you.
use data store, get async and set async to load and save data
local d = game:GetService("DataStoreService"):GetDataStore() game.Players.PlayerAdded:Connect(function(p) if d:GetAsync(p.userId) ~= nil then p.Character:WaitForChild("Humanoid").JumpPower = d:GetAsync(p.UserId)[1] end end) game.Players.PlayerRemoving:Connect(function(p) d:SetAsync(p.UserId,p.Character.Humanoid.JumpPower) end)
use player added and removing to get the player, make sure this is a server script in workspace or something k enjoy ur script, also remember to add a check to see if the data already exists. Click accept answer on this question if its correct