СТАРТ
local function check_start(x_part)
if x_part:IsA("VehicleSeat") == true then
workspace.Finish.Transparency = 0
workspace.Start.Transparency = 1
local timer = Instance.new("NumberValue")
timer.Name = "RaseTimer"
timer.Parent = game.ServerStorage
timer.Value = tick()
script.Disabled = true
workspace.Finish:FindFirstChildOfClass("Script").Disabled = false
end
end
script.Parent.Touched:Connect(check_start)
ФИНИШ
local function Round(n, decimals)
decimals = decimals or 0
return math.floor(n * 10^decimals) / 10^decimals
end
local function check_finish( x_part )
if x_part:IsA("VehicleSeat") == true then
workspace.Finish.Transparency = 1
workspace.Finish.Transparency = 1
workspace.Start.Transparency = 0
local timer = game.ServerStorage:FindFirstChild("RaseTimer")
print("Гонка закончилась", timer.Value)
local raceTimeResult = tick() - timer.Value
raceTimeResult = Round(raceTimeResult, 2)
print(raceTimeResult, "секунд прошло")
script.Disabled = true
workspace.Finish:FindFirstChildOfClass("Script").Disabled = true
wait(3)
workspace.Start:FindFirstChildOfClass("Script").Disabled = false
end
end
script.Parent.Touched:Connect(check_finish)
ТАЙМ
function Round(n, decimals)
decimals = decimals or 0
return math.floor(n * 10^decimals) / 10^decimals
end
local last_time = 0
local debounce = true
local BeginRace = game.Workspace.Start.Script
local EndRace = game.Workspace.Finish.Script
local TextLabel = script.Parent.TextLabel
while true do
if BeginRace.Disabled and debounce then
debounce = false
local timer_status = true
local timeStart = tick()
while timer_status do
local raceTimeResult = tick() - timeStart
raceTimeResult = Round(raceTimeResult, 2)
last_time = raceTimeResult
TextLabel.Text = "Time:"..tostring(last_time)
if EndRace.Disabled then
timer_status = false
wait(5)
debounce = true
break
end
wait()
end
end
wait()
end