Advertisement
NasuiAlexandra

Timer Gui Part Roblox Studio

Jan 26th, 2021
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.31 KB | None | 0 0
  1. local start = game.Workspace.Start
  2.  
  3. local stop = game.Workspace.Stop
  4.  
  5.  
  6.  
  7. local time_val = 10
  8.  
  9. local timer_started = false
  10.  
  11. local completed = false
  12.  
  13.  
  14.  
  15. local time_label = script.Parent
  16.  
  17. time_label.Visible = false
  18.  
  19.  
  20.  
  21. local LPlayer = game.Players.LocalPlayer
  22.  
  23.  
  24.  
  25. local function start_timer(otherPart)
  26.  
  27.     local player = game.Players:FindFirstChild(otherPart.Parent.Name)
  28.  
  29.     if player.Name == LPlayer.Name and not timer_started then
  30.  
  31.         timer_started = true
  32.  
  33.         time_label.Text = time_val
  34.  
  35.         player.PlayerGui.Timer.Label.Visible = true
  36.  
  37.         local time_num = tonumber(player.PlayerGui.Timer.Label.Text)
  38.  
  39.         while time_num > 0 do
  40.  
  41.             wait(1)
  42.  
  43.             time_num = time_num - 1
  44.  
  45.             player.PlayerGui.Timer.Label.Text = tostring(time_num)
  46.  
  47.         end
  48.  
  49.         if not completed then
  50.  
  51.             player.PlayerGui.Timer.Label.Visible = false
  52.  
  53.             player.Character.Humanoid.Health = 0
  54.  
  55.         end
  56.  
  57.         timer_started = false
  58.  
  59.         completed = false
  60.  
  61.         player.PlayerGui.Timer.Label.Text = time_val
  62.  
  63.     end
  64.  
  65. end
  66.  
  67.  
  68.  
  69. local function finish_timer(otherPart)
  70.  
  71.     local player = game.Players:FindFirstChild(otherPart.Parent.Name)
  72.  
  73.     if player.Name == LPlayer.Name then
  74.  
  75.         player.PlayerGui.Timer.Label.Visible = false
  76.  
  77.         completed = true
  78.  
  79.     end
  80.  
  81. end
  82.  
  83.  
  84.  
  85. start.Touched:Connect(start_timer)
  86.  
  87. stop.Touched:Connect(finish_timer)
  88.  
  89.  
  90.  
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement