Hi! So the script is a timer aka a stopwatch that commences when someone touches the part : "Timer_Start" And make it pause at "Timer_Pause" ( I AM NOT USING THE " Timer_Stop")

I would like to make this as a leaderstats!? for example it saves the greatest time in leaderstats called "BestTime" And Slowest time as "Slowest time" Now here is the stopwatch timer that is located in : SpeedRun Timer / SpeedRunTimerGUI / MainScript (its local)

local par=script.Parent

local timer=par:WaitForChild'Timer'
local timerlabel=timer:WaitForChild'Time'

local toggle=par:WaitForChild'ToggleButton'

function connectplrtouch(pt,func)
	pt.Touched:Connect(function(t)
		local c=game.Players.LocalPlayer.Character
		if c and t:IsDescendantOf(c) then
			func()

		end
	end)
end

local timer_active=false
local timer_time=0

function updatetogglebutton()
	toggle.Text=timer.Visible and 'Hide Timer' or 'Show Timer'
end
updatetogglebutton()

toggle.MouseButton1Click:Connect(function()
	timer.Visible=not timer.Visible
	updatetogglebutton()
end)

local prev
for _,d in pairs(workspace:GetDescendants()) do
	if d.Name=='Timer_Start' then
		local name=(d:FindFirstChild'Title' and d.Title:IsA'StringValue' and d.Title.Value) or ''
		connectplrtouch(d,function()
			par.Enabled=true
			if prev~=d then
				timer_time=0
				prev=d
			end
			timerlabel.TextColor3=Color3.new(0,1,0)
			updatetogglebutton()
			timer_active=true
		end)
	end
	if d.Name=='Timer_Pause' then
		connectplrtouch(d,function()
			timerlabel.TextColor3=Color3.new(0,1,1)
			timer_active=false
		end)
	end
	if d.Name=='Timer_Stop' then
		connectplrtouch(d,function()
			par.Enabled=false
			timerlabel.TextColor3=Color3.new(1,0,0)
			timer_active=false
			timer_time=0
		end)
	end
end

while wait(.1) do
	if timer_active then
		timer_time=timer_time+1
		local txt=math.floor(timer_time)/10
		local int,dec=math.modf(txt)
		if dec<.09 then txt=(txt..'.0')end
		timerlabel.Text=txt
	end
end

And the main leaderstats script that works fine is :

Irrelevent because all i need is to save those times!

(could someone write the code for me?) I can't do it i have worked on this for 2 months and got no progress

2 comments

0

Judging by this code and your request, I am assuming you didn't write this program. Unfortunately, this website isn't for programming requests; if you wish for someone with expertise to make your desired script, go to Fiverr.

0

The timer_time variable contains the recorded delta. Use that to paired with a conditional to determine best & worst times. If you still struggle, I am a freelance scripter myself. My Discord is in my Bio.