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")

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

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
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")
if playerRace ~= 0 then
    game.Players.LocalPlayer.PlayerGui.Ninjutsu.Value = playerRace
else
    print("Nothing to load")
end
end 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