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

any help with my stat saving script?

Asked by 9 years ago

I'm trying to make a naruto game that has stats and every 0.5 seconds it saves the stats let me give you how the details are of studio I need help knowing where are the errors

  1. I put a localscript in workspace
  2. here is the script below "3." is the script. 3.I have a model named stats in the starterGui and what is within it is "Ninjutsu and "TaiJutsu" game starterGui stats Ninjutsu TaiJutsu --heres the script- wait(0.5)

local n = game:GetService("DataStoreService"):GetDataStore("Ninjutsu") local t = game:GetService("DataStoreService"):GetDataStore("Taijutsu") while true do wait(0.5) function saveRace(player, ninjutsu) player:SaveNumber("Ninjutsu", ninjutsu) end

function loadRace(player, ninjutsu) local playerRace = player:LoadNumber("Ninjutsu")

1if playerRace ~= 0 then
2    game.Players.LocalPlayer.PlayerGui.Ninjutsu.Value = playerRace
3else
4    print("Nothing to load")
5end

end end

So I did this but It doesnt save when I reset(Die) or when I rejoin what are the errors? Output doesnt show anything nor the command bar! HELP!

2 answers

Log in to vote
0
Answered by 9 years ago

I just want it to save when a player dies and rejoins

Ad
Log in to vote
0
Answered by 9 years ago
01local n = game:GetService("DataStoreService"):GetDataStore("Ninjutsu")
02local t = game:GetService("DataStoreService"):GetDataStore("Taijutsu")
03while true do
04wait(0.5)
05function saveRace(player, ninjutsu)
06player:SaveNumber("Ninjutsu", ninjutsu)
07end
08 
09function loadRace(player, ninjutsu) local playerRace = player:LoadNumber("Ninjutsu")
10if playerRace ~= 0 then
11    game.Players.LocalPlayer.PlayerGui.Ninjutsu.Value = playerRace
12else
13    print("Nothing to load")
14end
15end end

Just decided to clean this up if anyone wanted to answer it, I am going to edit this to make it an answer, though.

Answer this question