local DataStores = game:GetService("DataStoreService") local FirstDataStore = DataStores:GetDataStore("JumpPowerStorage") game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) wait(0.1) player.Character.Humanoid.JumpPower = FirstDataStore:GetAsync(player.UserId) or 50 FirstDataStore:SetAsync(player.UserId, player.Character.Humanoid.JumpPower) player.Character.Humanoid.Changed:connect(function() wait(2) FirstDataStore:SetAsync(player.UserId, player.Character.Humanoid.JumpPower) end) end) end) game.Players.PlayerRemoving:connect(function(player) FirstDataStore:SetAsync(player.UserId, player.Character.Humanoid.JumpPower) end)
A person here a while ago gave me this script however it keeps returning async errors... any way how to fix?
local DataStore = game:GetService(“DataStoreService”) local DataStoreOne = DataStore:GetDataStore(“JumpPower”) local Default = 50 — All new players will start with this JP game.Players.PlayerAdded:Connect(function(Player) repeat wait() until Player.Character ~= nil local JumpPower = Player.Character.Humanoid.JumpPower JumpPower = DataStoreOne:GetAsync(Player.UserId) or Default DataStoreOne:SetAsync(Player.UserId, JumpPower) end) game.Players.PlayerRemoving:Connect(function(Player) local JumpPower = Player.Character.Humanoid.JumpPower DataStoreOne:SetAsync(Player.UserId, JumpPower) end)
This script should work. I did modify a few things. First, I wouldn’t worry about updating the DataStore every time the value is changed. Chances are, saving it once upon joining and leaving is enough. Also, I changed your WaitForCharacter function to something that I feel is more reliable. Last, I just added the default jump power as a variable so you can change it at your own convenience.
Keep in mind that this script should work fine in game, and errors are more persistent in the studio. If you have any issues in studio, just publish it and try it out. Other than that, you can enable studio access to API services in the configuration page for your game to modify the DataStore from the studio. Good luck with your game!