Found this script in the toolbox. It saves a list of items and I’m wondering if it is a virus. I have no idea what httpservice does and why they would need it.
script:
local scope = 'Game' --Switch it to 'Game' when you publish it, so saved data from test won't transfer over to the real game
local ss = game:GetService('ReplicatedStorage')
local ps = game:GetService('Players')
local ds = game:GetService('DataStoreService'):GetDataStore('PlayerData',scope)
local hs = game:GetService('HttpService') --What is this??? Virus???????
local dataFolder = ss:WaitForChild('PlayerData')
local storeFolder = dataFolder:WaitForChild('Store') --where each players' folder will be
local defaultFolder = dataFolder:WaitForChild('Default-Data')
local prepareFolder = function(player,data)
local playerFolder = storeFolder:FindFirstChild(player.Name)
local newData = hs:JSONDecode(data)
if not playerFolder then
local folder = defaultFolder:Clone(); folder.Name = player.Name; folder.Parent = storeFolder
playerFolder = folder
end
for name,value in pairs(newData) do
local objInDefault = defaultFolder:FindFirstChild(name) --doesn't create a value obj for anything if it doesnt exist in defaultFolder
if objInDefault then
playerFolder[name].Value = value
end
end
return playerFolder
end
local savePlayerData = function(player)
local playerFolder = storeFolder:FindFirstChild(player.Name)
if not playerFolder then
local folder = defaultFolder:Clone(); folder.Name = player.Name; folder.Parent = storeFolder
playerFolder = folder
end
local dataList = {} --Saves it into a list as a key-value pairs, key is the name, value is the objects value
for i,value in pairs(defaultFolder:GetChildren()) do
--Since only values with names matching from defaultFolder will be saved, you can put any value you like
local currentSaving = playerFolder[value.Name] -- value is an instance object
if not currentSaving then
local newObj = value:Clone(); newObj.Parent = playerFolder
end
dataList[value.Name] = currentSaving.Value
end
dataList = hs:JSONEncode(dataList)
ds:SetAsync(player.userId,dataList)
return dataList,playerFolder
end
local fetchPlayerData = function(player)
local newData = ds:GetAsync(player.userId)
if not newData then
newData = savePlayerData(player) --saves the data if no previous saves exists and returns it
end
local playerFolder = prepareFolder(player,newData)
return playerFolder
end
ps.PlayerAdded:connect(function(player)
fetchPlayerData(player)
end)
--Sometimes this connection can't be made for the fircst player (happens mostly in studio)
if ps.NumPlayers >= 1 then
for i,player in pairs(ps:GetPlayers()) do
if not storeFolder[player.Name] then
fetchPlayerData(player)--gets their data if its not in there
end
end
end
ps.PlayerRemoving:connect(function(player)
local _,folder = savePlayerData(player) --we need the second returned value so ignore the first one by using _
folder:Destroy()
end)