Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 answers

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

2 comments

0

Just did

0

Right, it is possible through Data Stores or Data Presistance. Check the wiki for more info

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.