Sword Fighting Game

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

image

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```

and the TimeScript where you get time is:

local humanoid = character.Humanoid

local player = game.Players:GetPlayerFromCharacter(character)

local leaderstats = player.leaderstats
local timeAlive = leaderstats["Time Alive"]
local bestTime = leaderstats["Best Time"]

local regionPart = workspace.Region

local min = regionPart.Position - (0.5 * regionPart.Size)
local max = regionPart.Position + (0.5 * regionPart.Size)
local region = Region3.new(min, max)

local function CheckSpawnRegion()
	local objects = workspace:FindPartsInRegion3WithWhiteList(region, {character})
	
	if #objects > 0 then
		if not character:FindFirstChildOfClass("ForceField") then
			local forceField = Instance.new("ForceField")
			forceField.Visible = true
			forceField.Parent = character
		end
		
		return true
	else
		local forceField = character:FindFirstChildOfClass("ForceField")
		
		if forceField then
			forceField:Destroy()
		end
		
		return false
	end
end

local hasDied = false

humanoid.Died:Connect(function()
	hasDied = true
end)

while wait() do
	if hasDied then break end
	
	while not hasDied and not CheckSpawnRegion() do
		timeAlive.Value += 1
		
		if timeAlive.Value > bestTime.Value then
			bestTime.Value = timeAlive.Value
		end
		
		wait(1)
	end
	
	if hasDied then
		timeAlive.Value = 0
	end
end```

I want the time overhead gui to match with the leader stats and the 10 time area which gives you 10 times of the time