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

How can I save a IntValue and a StringValue in workspace?

Asked by 9 years ago

How can I auto save a **IntValue ** and a **StringValue ** in workspace? Is it possible?

2 answers

Log in to vote
0
Answered by 9 years ago

Could you explain in a little more detail? An example would be nice too

0
Just did PancakeAttacks 0 — 9y
0
Right, it is possible through Data Stores or Data Presistance. Check the wiki for more info fahmisack123 385 — 9y
Ad
Log in to vote
-1
Answered by 9 years ago

Something like this except in workspace .

function onPlayerEntered(player)
wait(4)-- Change to wait for player longer.
player:WaitForDataReady()
repeat wait() until player:FindFirstChild("leaderstats")
if player.DataReady then
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
local ScoreLoaded = player:LoadNumber(score[i].Name)
wait()
if ScoreLoaded ~= 0 then
score[i].Value = ScoreLoaded
end
end
end
end
end

function onPlayerLeaving(player)
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
player:SaveNumber(score[i].Name,score[i].Value)
end
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)
game.Players.PlayerRemoving:connect(onPlayerLeaving)

Answer this question