Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a script to save my JumpPower?

Asked by 4 years ago

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.

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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

0
Thank you User#29585 0 — 4y
0
np greatneil80 2647 — 4y
Ad

Answer this question