Hello! I’m looking for a scripter that can help me out! I’m looking for a 10 time area script which will give you 10 times of time and a time overhead which will match with the leader stats
The Serverscript DataStore code is:
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStore")
local function CreateStat(name, class, value, parent)
local stat = Instance.new(class)
stat.Name = name
stat.Value = value
stat.Parent = parent
return stat
end
local function GetKey(player)
return player.UserId .. "-"
end
local function SaveData(player)
local key = GetKey(player)
local leaderstats = player.leaderstats
local timeAliveData = leaderstats["Time Alive"].Value
local bestTimeData = leaderstats["Best Time"].Value
local success, result = pcall(function()
DataStore:SetAsync(key .. "TimeAlive", timeAliveData)
DataStore:SetAsync(key .. "BestTime", bestTimeData)
end)
if not success then
warn(result)
end
end
game.Players.PlayerAdded:Connect(function(player)
local key = GetKey(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local timeAlive = CreateStat("Time Alive", "IntValue", 0, leaderstats)
local bestTime = CreateStat("Best Time", "IntValue", 0, leaderstats)
local timeAliveData, bestTimeData
local success, result = pcall(function()
timeAliveData = DataStore:GetAsync(key .. "TimeAlive")
bestTimeData = DataStore:GetAsync(key .. "BestTime")
end)
if success then
timeAlive.Value = timeAliveData or 0
bestTime.Value = bestTimeData or 0
else
warn(result)
player:Kick("Error occured while retrieving your saved data.")
end
end)
game.Players.PlayerRemoving:Connect(SaveData)
if not RunService:IsStudio() then
game:BindToClose(function()
if #game.Players:GetPlayers() <= 1 then return end
for _, player in pairs(game.Players:GetPlayers()) do
SaveData(player)
end
end)
end```