KrYn0MoRe

key press minigame

Jan 28th, 2022 (edited)
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.75 KB | None | 0 0
  1.  
  2. --Converted with ttyyuu12345's model to script plugin v4
  3. function sandbox(var,func)
  4.     local env = getfenv(func)
  5.     local newenv = setmetatable({},{
  6.         __index = function(self,k)
  7.             if k=="script" then
  8.                 return var
  9.             else
  10.                 return env[k]
  11.             end
  12.         end,
  13.     })
  14.     setfenv(func,newenv)
  15.     return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Part0 = Instance.new("Part")
  20. SurfaceGui1 = Instance.new("SurfaceGui")
  21. Frame2 = Instance.new("Frame")
  22. TextLabel3 = Instance.new("TextBox")
  23. Frame4 = Instance.new("Frame")
  24. Frame5 = Instance.new("Frame")
  25. Frame6 = Instance.new("Frame")
  26. Frame7 = Instance.new("Frame")
  27. Frame8 = Instance.new("Frame")
  28. Frame9 = Instance.new("Frame")
  29. Frame10 = Instance.new("Frame")
  30. TextLabel11 = Instance.new("TextBox")
  31. TextLabel12 = Instance.new("TextBox")
  32. TextLabel13 = Instance.new("TextBox")
  33. TextLabel14 = Instance.new("TextBox")
  34. TextLabel15 = Instance.new("TextBox")
  35. TextLabel16 = Instance.new("TextBox")
  36. TextLabel17 = Instance.new("TextBox")
  37. Frame18 = Instance.new("Frame")
  38. TextLabel19 = Instance.new("TextBox")
  39. TextLabel20 = Instance.new("TextBox")
  40. ScrollingFrame21 = Instance.new("ScrollingFrame")
  41. UIGridLayout22 = Instance.new("UIGridLayout")
  42. Frame23 = Instance.new("Frame")
  43. TextLabel24 = Instance.new("TextBox")
  44. TextLabel25 = Instance.new("TextBox")
  45. Part0.Name = "board"
  46. Part0.Parent = mas
  47. Part0.CFrame = CFrame.new(0, 6.7, -25, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  48. Part0.Position = Vector3.new(0, 6.7, -25)
  49. Part0.Color = Color3.new(0, 0, 0)
  50. Part0.Size = Vector3.new(0.8999998569488525, 13.40000057220459, 21.899999618530273)
  51. Part0.Anchored = true
  52. Part0.BottomSurface = Enum.SurfaceType.Smooth
  53. Part0.BrickColor = BrickColor.new("Really black")
  54. Part0.Material = Enum.Material.SmoothPlastic
  55. Part0.TopSurface = Enum.SurfaceType.Smooth
  56. Part0.brickColor = BrickColor.new("Really black")
  57. SurfaceGui1.Parent = Part0
  58. SurfaceGui1.Face = Enum.NormalId.Left
  59. SurfaceGui1.ClipsDescendants = true
  60. SurfaceGui1.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  61. SurfaceGui1.Adornee = Part0
  62. Frame2.Name = "main"
  63. Frame2.Parent = SurfaceGui1
  64. Frame2.Size = UDim2.new(1, 0, 1, 0)
  65. Frame2.BackgroundColor = BrickColor.new("Really black")
  66. Frame2.BackgroundColor3 = Color3.new(0, 0, 0)
  67. TextLabel3.Name = "title"
  68. TextLabel3.Parent = Frame2
  69. TextLabel3.Position = UDim2.new(0.5, 0, 0.5, 0)
  70. TextLabel3.Size = UDim2.new(1, 0, 0.300000012, 0)
  71. TextLabel3.AnchorPoint = Vector2.new(0.5, 0.5)
  72. TextLabel3.BackgroundColor = BrickColor.new("Institutional white")
  73. TextLabel3.BackgroundColor3 = Color3.new(1, 1, 1)
  74. TextLabel3.BackgroundTransparency = 1
  75. TextLabel3.Font = Enum.Font.SourceSans
  76. TextLabel3.FontSize = Enum.FontSize.Size14
  77. TextLabel3.Text = [[Press "E" to enter the minigame!
  78. Press the key that shows up before the timer runs out!]]
  79. TextLabel3.TextColor = BrickColor.new("Institutional white")
  80. TextLabel3.TextColor3 = Color3.new(1, 1, 1)
  81. TextLabel3.TextScaled = true
  82. TextLabel3.TextSize = 14
  83. TextLabel3.TextStrokeTransparency = 0
  84. TextLabel3.TextWrap = true
  85. TextLabel3.TextWrapped = true
  86. Frame4.Name = "game"
  87. Frame4.Parent = Frame2
  88. Frame4.Visible = false
  89. Frame4.Size = UDim2.new(1, 0, 1, 0)
  90. Frame4.BackgroundColor = BrickColor.new("Really black")
  91. Frame4.BackgroundColor3 = Color3.new(0, 0, 0)
  92. Frame4.ZIndex = 2
  93. Frame5.Name = "bar"
  94. Frame5.Parent = Frame4
  95. Frame5.Position = UDim2.new(0.5, 0, 0.100000001, 0)
  96. Frame5.Size = UDim2.new(0.899999976, 0, 0.0700000003, 0)
  97. Frame5.AnchorPoint = Vector2.new(0.5, 0.5)
  98. Frame5.BackgroundColor = BrickColor.new("Medium brown")
  99. Frame5.BackgroundColor3 = Color3.new(0.227451, 0.227451, 0.227451)
  100. Frame5.BorderColor = BrickColor.new("Lilac")
  101. Frame5.BorderColor3 = Color3.new(0.443137, 0.356863, 0.701961)
  102. Frame5.BorderSizePixel = 3
  103. Frame6.Name = "left"
  104. Frame6.Parent = Frame5
  105. Frame6.Size = UDim2.new(0.999885321, 0, 1, 0)
  106. Frame6.BackgroundColor = BrickColor.new("Lime green")
  107. Frame6.BackgroundColor3 = Color3.new(0, 1, 0)
  108. Frame6.BorderSizePixel = 0
  109. Frame7.Name = "split"
  110. Frame7.Parent = Frame5
  111. Frame7.Position = UDim2.new(0.25, 0, 0, 0)
  112. Frame7.Size = UDim2.new(0, 5, 1, 0)
  113. Frame7.BackgroundColor = BrickColor.new("Really black")
  114. Frame7.BackgroundColor3 = Color3.new(0, 0, 0)
  115. Frame7.BorderSizePixel = 0
  116. Frame7.ZIndex = 2
  117. Frame8.Name = "split"
  118. Frame8.Parent = Frame5
  119. Frame8.Position = UDim2.new(0.5, 0, 0, 0)
  120. Frame8.Size = UDim2.new(0, 5, 1, 0)
  121. Frame8.BackgroundColor = BrickColor.new("Really black")
  122. Frame8.BackgroundColor3 = Color3.new(0, 0, 0)
  123. Frame8.BorderSizePixel = 0
  124. Frame8.ZIndex = 2
  125. Frame9.Name = "split"
  126. Frame9.Parent = Frame5
  127. Frame9.Position = UDim2.new(0.75, 0, 0, 0)
  128. Frame9.Size = UDim2.new(0, 5, 1, 0)
  129. Frame9.BackgroundColor = BrickColor.new("Really black")
  130. Frame9.BackgroundColor3 = Color3.new(0, 0, 0)
  131. Frame9.BorderSizePixel = 0
  132. Frame9.ZIndex = 2
  133. Frame10.Name = "input"
  134. Frame10.Parent = Frame4
  135. Frame10.Position = UDim2.new(0.5, 0, 0.646000028, 0)
  136. Frame10.Size = UDim2.new(0.528440416, 0, 0.603418827, 0)
  137. Frame10.AnchorPoint = Vector2.new(0.5, 0.5)
  138. Frame10.BackgroundColor = BrickColor.new("Really black")
  139. Frame10.BackgroundColor3 = Color3.new(0, 0, 0)
  140. Frame10.BorderColor = BrickColor.new("Institutional white")
  141. Frame10.BorderColor3 = Color3.new(1, 1, 1)
  142. Frame10.BorderSizePixel = 3
  143. TextLabel11.Name = "key"
  144. TextLabel11.Parent = Frame10
  145. TextLabel11.Position = UDim2.new(0.5, 0, 0.5, 0)
  146. TextLabel11.Size = UDim2.new(0.5, 0, 0.5, 0)
  147. TextLabel11.AnchorPoint = Vector2.new(0.5, 0.5)
  148. TextLabel11.BackgroundColor = BrickColor.new("Institutional white")
  149. TextLabel11.BackgroundColor3 = Color3.new(1, 1, 1)
  150. TextLabel11.BackgroundTransparency = 1
  151. TextLabel11.Font = Enum.Font.SourceSans
  152. TextLabel11.FontSize = Enum.FontSize.Size14
  153. TextLabel11.Text = "A"
  154. TextLabel11.TextColor = BrickColor.new("Institutional white")
  155. TextLabel11.TextColor3 = Color3.new(1, 1, 1)
  156. TextLabel11.TextScaled = true
  157. TextLabel11.TextSize = 14
  158. TextLabel11.TextStrokeTransparency = 0
  159. TextLabel11.TextWrap = true
  160. TextLabel11.TextWrapped = true
  161. TextLabel12.Name = "time"
  162. TextLabel12.Parent = Frame4
  163. TextLabel12.Position = UDim2.new(0.899999976, 0, 0.970000029, 0)
  164. TextLabel12.Size = UDim2.new(0.200000003, 0, 0.0495470352, 0)
  165. TextLabel12.AnchorPoint = Vector2.new(0.5, 0.5)
  166. TextLabel12.BackgroundColor = BrickColor.new("Institutional white")
  167. TextLabel12.BackgroundColor3 = Color3.new(1, 1, 1)
  168. TextLabel12.BackgroundTransparency = 1
  169. TextLabel12.Font = Enum.Font.SourceSans
  170. TextLabel12.FontSize = Enum.FontSize.Size14
  171. TextLabel12.Text = "time: 0"
  172. TextLabel12.TextColor = BrickColor.new("Institutional white")
  173. TextLabel12.TextColor3 = Color3.new(1, 1, 1)
  174. TextLabel12.TextScaled = true
  175. TextLabel12.TextSize = 14
  176. TextLabel12.TextStrokeTransparency = 0
  177. TextLabel12.TextWrap = true
  178. TextLabel12.TextWrapped = true
  179. TextLabel12.TextXAlignment = Enum.TextXAlignment.Left
  180. TextLabel13.Name = "players"
  181. TextLabel13.Parent = Frame4
  182. TextLabel13.Position = UDim2.new(0.899999976, 0, 0.920000017, 0)
  183. TextLabel13.Size = UDim2.new(0.200000003, 0, 0.0495470352, 0)
  184. TextLabel13.AnchorPoint = Vector2.new(0.5, 0.5)
  185. TextLabel13.BackgroundColor = BrickColor.new("Institutional white")
  186. TextLabel13.BackgroundColor3 = Color3.new(1, 1, 1)
  187. TextLabel13.BackgroundTransparency = 1
  188. TextLabel13.Font = Enum.Font.SourceSans
  189. TextLabel13.FontSize = Enum.FontSize.Size14
  190. TextLabel13.Text = "players left: 0"
  191. TextLabel13.TextColor = BrickColor.new("Institutional white")
  192. TextLabel13.TextColor3 = Color3.new(1, 1, 1)
  193. TextLabel13.TextScaled = true
  194. TextLabel13.TextSize = 14
  195. TextLabel13.TextStrokeTransparency = 0
  196. TextLabel13.TextWrap = true
  197. TextLabel13.TextWrapped = true
  198. TextLabel13.TextXAlignment = Enum.TextXAlignment.Left
  199. TextLabel14.Name = "mode"
  200. TextLabel14.Parent = Frame4
  201. TextLabel14.Position = UDim2.new(0.899999976, 0, 0.870000005, 0)
  202. TextLabel14.Size = UDim2.new(0.200000003, 0, 0.0495470352, 0)
  203. TextLabel14.AnchorPoint = Vector2.new(0.5, 0.5)
  204. TextLabel14.BackgroundColor = BrickColor.new("Institutional white")
  205. TextLabel14.BackgroundColor3 = Color3.new(1, 1, 1)
  206. TextLabel14.BackgroundTransparency = 1
  207. TextLabel14.Font = Enum.Font.SourceSans
  208. TextLabel14.FontSize = Enum.FontSize.Size14
  209. TextLabel14.Text = "mode: elimination"
  210. TextLabel14.TextColor = BrickColor.new("Institutional white")
  211. TextLabel14.TextColor3 = Color3.new(1, 1, 1)
  212. TextLabel14.TextScaled = true
  213. TextLabel14.TextSize = 14
  214. TextLabel14.TextStrokeTransparency = 0
  215. TextLabel14.TextWrap = true
  216. TextLabel14.TextWrapped = true
  217. TextLabel14.TextXAlignment = Enum.TextXAlignment.Left
  218. TextLabel15.Name = "info"
  219. TextLabel15.Parent = Frame4
  220. TextLabel15.Position = UDim2.new(0.499885321, 0, 0.25, 0)
  221. TextLabel15.Size = UDim2.new(1, 0, 0.100000001, 0)
  222. TextLabel15.AnchorPoint = Vector2.new(0.5, 0.5)
  223. TextLabel15.BackgroundColor = BrickColor.new("Institutional white")
  224. TextLabel15.BackgroundColor3 = Color3.new(1, 1, 1)
  225. TextLabel15.BackgroundTransparency = 1
  226. TextLabel15.Font = Enum.Font.SourceSans
  227. TextLabel15.FontSize = Enum.FontSize.Size14
  228. TextLabel15.Text = "Press the key below before the timer above runs out!"
  229. TextLabel15.TextColor = BrickColor.new("Institutional white")
  230. TextLabel15.TextColor3 = Color3.new(1, 1, 1)
  231. TextLabel15.TextScaled = true
  232. TextLabel15.TextSize = 14
  233. TextLabel15.TextStrokeTransparency = 0
  234. TextLabel15.TextWrap = true
  235. TextLabel15.TextWrapped = true
  236. TextLabel16.Name = "timer"
  237. TextLabel16.Parent = Frame2
  238. TextLabel16.Position = UDim2.new(0.5, 0, 0.850000024, 0)
  239. TextLabel16.Size = UDim2.new(1, 0, 0.100000001, 0)
  240. TextLabel16.AnchorPoint = Vector2.new(0.5, 0.5)
  241. TextLabel16.BackgroundColor = BrickColor.new("Institutional white")
  242. TextLabel16.BackgroundColor3 = Color3.new(1, 1, 1)
  243. TextLabel16.BackgroundTransparency = 1
  244. TextLabel16.Font = Enum.Font.SourceSans
  245. TextLabel16.FontSize = Enum.FontSize.Size14
  246. TextLabel16.Text = "Time left to join: N/A"
  247. TextLabel16.TextColor = BrickColor.new("Institutional white")
  248. TextLabel16.TextColor3 = Color3.new(1, 1, 1)
  249. TextLabel16.TextScaled = true
  250. TextLabel16.TextSize = 14
  251. TextLabel16.TextStrokeTransparency = 0
  252. TextLabel16.TextWrap = true
  253. TextLabel16.TextWrapped = true
  254. TextLabel17.Name = "queue"
  255. TextLabel17.Parent = Frame2
  256. TextLabel17.Position = UDim2.new(0.5, 0, 0.949999988, 0)
  257. TextLabel17.Size = UDim2.new(1, 0, 0.100000001, 0)
  258. TextLabel17.AnchorPoint = Vector2.new(0.5, 0.5)
  259. TextLabel17.BackgroundColor = BrickColor.new("Institutional white")
  260. TextLabel17.BackgroundColor3 = Color3.new(1, 1, 1)
  261. TextLabel17.BackgroundTransparency = 1
  262. TextLabel17.Font = Enum.Font.SourceSans
  263. TextLabel17.FontSize = Enum.FontSize.Size14
  264. TextLabel17.Text = "In queue: N/A"
  265. TextLabel17.TextColor = BrickColor.new("Institutional white")
  266. TextLabel17.TextColor3 = Color3.new(1, 1, 1)
  267. TextLabel17.TextScaled = true
  268. TextLabel17.TextSize = 14
  269. TextLabel17.TextStrokeTransparency = 0
  270. TextLabel17.TextWrap = true
  271. TextLabel17.TextWrapped = true
  272. Frame18.Name = "finish"
  273. Frame18.Parent = Frame2
  274. Frame18.Visible = false
  275. Frame18.Size = UDim2.new(1, 0, 1, 0)
  276. Frame18.BackgroundColor = BrickColor.new("Really black")
  277. Frame18.BackgroundColor3 = Color3.new(0, 0, 0)
  278. Frame18.ZIndex = 3
  279. TextLabel19.Name = "timer"
  280. TextLabel19.Parent = Frame18
  281. TextLabel19.Position = UDim2.new(0.5, 0, 0.949999988, 0)
  282. TextLabel19.Size = UDim2.new(1, 0, 0.100000001, 0)
  283. TextLabel19.AnchorPoint = Vector2.new(0.5, 0.5)
  284. TextLabel19.BackgroundColor = BrickColor.new("Institutional white")
  285. TextLabel19.BackgroundColor3 = Color3.new(1, 1, 1)
  286. TextLabel19.BackgroundTransparency = 1
  287. TextLabel19.Font = Enum.Font.SourceSans
  288. TextLabel19.FontSize = Enum.FontSize.Size14
  289. TextLabel19.Text = "Display closes in: 0"
  290. TextLabel19.TextColor = BrickColor.new("Institutional white")
  291. TextLabel19.TextColor3 = Color3.new(1, 1, 1)
  292. TextLabel19.TextScaled = true
  293. TextLabel19.TextSize = 14
  294. TextLabel19.TextStrokeTransparency = 0
  295. TextLabel19.TextWrap = true
  296. TextLabel19.TextWrapped = true
  297. TextLabel20.Name = "title"
  298. TextLabel20.Parent = Frame18
  299. TextLabel20.Position = UDim2.new(0.5, 0, 0.0500000007, 0)
  300. TextLabel20.Size = UDim2.new(1, 0, 0.100000001, 0)
  301. TextLabel20.AnchorPoint = Vector2.new(0.5, 0.5)
  302. TextLabel20.BackgroundColor = BrickColor.new("Institutional white")
  303. TextLabel20.BackgroundColor3 = Color3.new(1, 1, 1)
  304. TextLabel20.BackgroundTransparency = 1
  305. TextLabel20.Font = Enum.Font.SourceSans
  306. TextLabel20.FontSize = Enum.FontSize.Size14
  307. TextLabel20.Text = "Leaderboard:"
  308. TextLabel20.TextColor = BrickColor.new("Institutional white")
  309. TextLabel20.TextColor3 = Color3.new(1, 1, 1)
  310. TextLabel20.TextScaled = true
  311. TextLabel20.TextSize = 14
  312. TextLabel20.TextStrokeTransparency = 0
  313. TextLabel20.TextWrap = true
  314. TextLabel20.TextWrapped = true
  315. ScrollingFrame21.Name = "list"
  316. ScrollingFrame21.Parent = Frame18
  317. ScrollingFrame21.Position = UDim2.new(0.5, 0, 0.100000001, 0)
  318. ScrollingFrame21.Size = UDim2.new(0.899999976, 0, 0.800000012, 0)
  319. ScrollingFrame21.Active = true
  320. ScrollingFrame21.AnchorPoint = Vector2.new(0.5, 0)
  321. ScrollingFrame21.BackgroundColor = BrickColor.new("Black")
  322. ScrollingFrame21.BackgroundColor3 = Color3.new(0.192157, 0.192157, 0.192157)
  323. ScrollingFrame21.ScrollBarThickness = 50
  324. UIGridLayout22.Parent = ScrollingFrame21
  325. UIGridLayout22.FillDirection = Enum.FillDirection.Vertical
  326. UIGridLayout22.SortOrder = Enum.SortOrder.LayoutOrder
  327. UIGridLayout22.CellPadding = UDim2.new(0, 0, 0, 10)
  328. UIGridLayout22.CellSize = UDim2.new(1, 0, 0, 100)
  329. Frame23.Name = "sample_list"
  330. Frame23.Parent = ScrollingFrame21
  331. Frame23.Size = UDim2.new(0, 100, 0, 100)
  332. Frame23.BackgroundColor = BrickColor.new("Institutional white")
  333. Frame23.BackgroundColor3 = Color3.new(1, 1, 1)
  334. Frame23.BackgroundTransparency = 1
  335. TextLabel24.Name = "plr"
  336. TextLabel24.Parent = Frame23
  337. TextLabel24.Size = UDim2.new(0.5, 0, 1, 0)
  338. TextLabel24.BackgroundColor = BrickColor.new("Institutional white")
  339. TextLabel24.BackgroundColor3 = Color3.new(1, 1, 1)
  340. TextLabel24.BackgroundTransparency = 1
  341. TextLabel24.Font = Enum.Font.SourceSans
  342. TextLabel24.FontSize = Enum.FontSize.Size14
  343. TextLabel24.Text = "Roblox"
  344. TextLabel24.TextColor = BrickColor.new("Institutional white")
  345. TextLabel24.TextColor3 = Color3.new(1, 1, 1)
  346. TextLabel24.TextScaled = true
  347. TextLabel24.TextSize = 14
  348. TextLabel24.TextStrokeTransparency = 0
  349. TextLabel24.TextWrap = true
  350. TextLabel24.TextWrapped = true
  351. TextLabel24.TextXAlignment = Enum.TextXAlignment.Left
  352. TextLabel25.Name = "time"
  353. TextLabel25.Parent = Frame23
  354. TextLabel25.Position = UDim2.new(0.5, 0, 0, 0)
  355. TextLabel25.Size = UDim2.new(0.5, 0, 1, 0)
  356. TextLabel25.BackgroundColor = BrickColor.new("Institutional white")
  357. TextLabel25.BackgroundColor3 = Color3.new(1, 1, 1)
  358. TextLabel25.BackgroundTransparency = 1
  359. TextLabel25.Font = Enum.Font.SourceSans
  360. TextLabel25.FontSize = Enum.FontSize.Size14
  361. TextLabel25.Text = "Time: 30"
  362. TextLabel25.TextColor = BrickColor.new("Institutional white")
  363. TextLabel25.TextColor3 = Color3.new(1, 1, 1)
  364. TextLabel25.TextScaled = true
  365. TextLabel25.TextSize = 14
  366. TextLabel25.TextStrokeTransparency = 0
  367. TextLabel25.TextWrap = true
  368. TextLabel25.TextWrapped = true
  369. TextLabel25.TextXAlignment = Enum.TextXAlignment.Left
  370. for i,v in pairs(mas:GetChildren()) do
  371.     v.Parent = script
  372.     pcall(function() v:MakeJoints() end)
  373. end
  374. mas:Destroy()
  375. for i,v in pairs(cors) do
  376.     spawn(function()
  377.         pcall(v)
  378.     end)
  379. end
  380.  
  381. local board = script.board
  382. local gui = board.SurfaceGui
  383. local main_ui = gui.main
  384. local game_ui = main_ui.game
  385. local finish_ui = main_ui.finish
  386. local sample_list = finish_ui.list.sample_list
  387.  
  388. gui.PixelsPerStud = 100
  389. gui.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
  390.  
  391. sample_list.Parent = nil
  392.  
  393. local join_prompt = Instance.new("ProximityPrompt")
  394. join_prompt.ClickablePrompt = false
  395. join_prompt.ActionText = 'Join Queue'
  396. join_prompt.GamepadKeyCode = Enum.KeyCode.E
  397. join_prompt.RequiresLineOfSight = false
  398. join_prompt.UIOffset = Vector2.new(0,-2)
  399. join_prompt.Exclusivity = Enum.ProximityPromptExclusivity.AlwaysShow
  400. join_prompt.HoldDuration = 0
  401. join_prompt.MaxActivationDistance = 15
  402. join_prompt.Parent = board
  403.  
  404. local game_info = {
  405.     max_time = 3,
  406.     low_time = 0.5,
  407.     time_dec = 0.2,
  408.     current_max_time = 0,
  409.     time = 0,
  410.     start_time = 0,
  411.     pressed = {},
  412.     players = {},
  413.     lose_time = {},
  414.     random_keys = 'bcefghjklmnpqrtu', -- wasd is removed because they are move keys, also 16 prompts can only be interacted with in same spot
  415.     key = '',
  416.     playing = 0,
  417.     mode = 'elimination' -- elimination, solo
  418. }
  419.  
  420. game_info.random_keys = string.upper(game_info.random_keys)
  421.  
  422. local function sleep(n)
  423.     return task.wait(n or 0)
  424. end
  425.  
  426. local function wrap(f)
  427.     return coroutine.wrap(f)()
  428. end
  429.  
  430. function update_bar()
  431.     local bar = game_ui.bar
  432.     local v = math.clamp((os.clock()-game_info.time)/game_info.current_max_time,0,1)
  433.     bar.left.Size = UDim2.new(v,0,1,0)
  434. end
  435.  
  436. function change_key()
  437.     local i = math.random(string.len(game_info.random_keys))
  438.     local key = string.sub(game_info.random_keys,i,i)
  439.     game_info.key = key
  440.     game_info.pressed = {}
  441. end
  442.  
  443. function update_player_input()
  444.     for plr,val in pairs(game_info.players) do
  445.         local char = plr.Character
  446.         if char then
  447.             local root = char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("Torso") or char:FindFirstChild("UpperTorso")
  448.             if root then
  449.                 for i = 1,string.len(game_info.random_keys) do
  450.                     local key = string.sub(game_info.random_keys,i,i)
  451.                     local prompt = root:FindFirstChild("randomkeys_prompt_" .. key)
  452.                     if not prompt then
  453.                         prompt = Instance.new("ProximityPrompt")
  454.                         prompt.Name = "randomkeys_prompt_" .. key
  455.                         prompt.ClickablePrompt = false
  456.                         prompt.Style = Enum.ProximityPromptStyle.Custom
  457.                        
  458.                         local keycode = Enum.KeyCode:GetEnumItems()
  459.                         for i,v in pairs(keycode) do
  460.                             if v.Name == key then
  461.                                 keycode = v
  462.                                 break
  463.                             end
  464.                         end
  465.                        
  466.                         prompt.GamepadKeyCode = keycode
  467.                         prompt.RequiresLineOfSight = false
  468.                         prompt.Exclusivity = Enum.ProximityPromptExclusivity.AlwaysShow
  469.                         prompt.HoldDuration = 0
  470.                         prompt.MaxActivationDistance = 0.01
  471.                         prompt.Parent = root
  472.                         prompt.Triggered:Connect(function(lplr)
  473.                             if lplr == plr then
  474.                                 if not game_info.pressed[plr] and game_info.players[plr] == 1 then
  475.                                     if game_info.key == key then
  476.                                         game_info.pressed[plr] = 1
  477.                                     else
  478.                                         game_info.players[plr] = 2
  479.                                     end
  480.                                 end
  481.                             end
  482.                         end)
  483.                     end
  484.                 end
  485.             end
  486.         end
  487.     end
  488. end
  489.  
  490. function stop()
  491.     game_ui.Visible = false
  492.    
  493.     for i,v in pairs(finish_ui.list:GetChildren()) do
  494.         if v:IsA("Frame") then
  495.             v:Destroy()
  496.         end
  497.     end
  498.     local lose_time = {}
  499.     for i,v in pairs(game_info.lose_time) do
  500.         local p = 1
  501.         for i,vv in pairs(lose_time) do
  502.             if v > vv[2] then
  503.                 p = i
  504.                 break
  505.             else
  506.                 p = i+1
  507.             end
  508.         end
  509.         table.insert(lose_time,p,{i,v})
  510.     end
  511.     for i,data in pairs(lose_time) do
  512.         local plr,val = unpack(data)
  513.         local c = sample_list:Clone()
  514.         c.plr.Text = plr -- player name instead of player, incase left
  515.         c.time.Text = val-(val%0.1)
  516.         local col = BrickColor.new("Fossil")
  517.         if i == 1 then
  518.             col = BrickColor.new("Gold")
  519.         elseif i == 2 then
  520.             col = BrickColor.new("Silver")
  521.         elseif i == 3 then
  522.             col = BrickColor.new("Bronze")
  523.         end
  524.         c.plr.TextColor = col
  525.         c.time.TextColor = col
  526.         c.Parent = finish_ui.list
  527.     end
  528.    
  529.     finish_ui.Visible = true
  530.    
  531.     local max = 5
  532.     for i = 1,max do
  533.         finish_ui.timer.Text = 'Display closes in: ' .. max-i
  534.         sleep(1)
  535.     end
  536.     finish_ui.Visible = false
  537.    
  538.     for plr,val in pairs(game_info.players) do
  539.         local char = plr.Character
  540.         if char then
  541.             local root = char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("Torso") or char:FindFirstChild("UpperTorso")
  542.             if root then
  543.                 for i = 1,string.len(game_info.random_keys) do
  544.                     local key = string.sub(game_info.random_keys,i,i)
  545.                     local prompt = root:FindFirstChild("randomkeys_prompt_" .. key)
  546.                     if prompt then
  547.                         prompt:Destroy()
  548.                     end
  549.                 end
  550.             end
  551.         end
  552.     end
  553.  
  554.     game_info.playing = 0
  555.     game_info.players = {}
  556.     join_prompt.Enabled = true
  557. end
  558.  
  559. function update_game()
  560.     update_bar()
  561.     local still_playing = {}
  562.     for plr,val in pairs(game_info.players) do
  563.         if val == 1 then
  564.             table.insert(still_playing,plr)
  565.         end
  566.     end
  567.     local t = os.clock()-game_info.start_time
  568.     t = t-(t%1)
  569.     game_ui.mode.Text = 'mode: ' .. game_info.mode
  570.     game_ui.players.Text = 'players left: ' .. #still_playing
  571.     game_ui.time.Text = 'time: ' .. t
  572.     game_ui.input.key.Text = game_info.key
  573.     game_ui.Visible = true
  574. end
  575.  
  576. function start()
  577.     join_prompt.Enabled = false
  578.     game_info.start_time = os.clock()
  579.     game_info.current_max_time = 1/0
  580.     game_info.key = nil
  581.     local c
  582.     c = game:GetService("RunService").Stepped:Connect(function()
  583.         if game_info.playing == 3 then
  584.             wrap(stop)
  585.             c:Disconnect()
  586.             return
  587.         end
  588.         if not game_info.key or os.clock()-game_info.time >= game_info.current_max_time then
  589.             game_info.time = os.clock()
  590.             game_info.current_max_time = math.clamp(game_info.current_max_time-game_info.time_dec,game_info.low_time,game_info.max_time)
  591.             if game_info.key then
  592.                 for plr,val in pairs(game_info.players) do
  593.                     if val == 1 and not game_info.pressed[plr] then
  594.                         game_info.players[plr] = 2
  595.                     end
  596.                 end
  597.             end
  598.             change_key()
  599.         end
  600.         update_player_input()
  601.         update_game()
  602.         local still_playing = {}
  603.         for plr,val in pairs(game_info.players) do
  604.             if val == 1 then
  605.                 table.insert(still_playing,plr)
  606.             end
  607.         end
  608.         for plr,val in pairs(game_info.players) do
  609.             if val == 1 then
  610.                 game_info.lose_time[plr.Name] = os.clock()-game_info.start_time -- keep setting if still playing
  611.             end
  612.         end
  613.         if (#still_playing > 1 and game_info.mode == 'elimination') or (#still_playing >= 1 and game_info.mode == 'solo') then else
  614.             game_info.playing = 3
  615.         end
  616.     end)
  617. end
  618.  
  619. function update_queue(reset)
  620.     local queue = {}
  621.     for plr,val in pairs(game_info.players) do
  622.         if plr and val == 1 then
  623.             table.insert(queue,plr)
  624.         end
  625.     end
  626.     if not reset and #queue >= 1 then
  627.         main_ui.queue.Text = 'In queue: ' .. #queue
  628.     else
  629.         main_ui.queue.Text = 'In queue: N/A'
  630.     end
  631. end
  632.  
  633. function run_queue()
  634.     if game_info.playing == 0 then
  635.         game_info.playing = 1
  636.         local max = 10
  637.         if game:GetService("RunService"):IsStudio() then
  638.             max = 0
  639.         end
  640.         wrap(function()
  641.             for i = 1,max do
  642.                 local queue = {}
  643.                 for plr,val in pairs(game_info.players) do
  644.                     if plr and val == 1 then
  645.                         table.insert(queue,plr)
  646.                     end
  647.                 end
  648.                 if #queue >= 1 then
  649.                     main_ui.timer.Text = 'Time left to join: ' .. max-i
  650.                     sleep(1)
  651.                 else
  652.                     main_ui.timer.Text = 'Time left to join: N/A'
  653.                     update_queue(true)
  654.                     game_info.playing = 0
  655.                     return
  656.                 end
  657.             end
  658.             game_info.playing = 2
  659.            
  660.             local queue = {}
  661.             for plr,val in pairs(game_info.players) do
  662.                 if plr and val == 1 then
  663.                     table.insert(queue,plr)
  664.                 end
  665.             end
  666.             if 1 >= #queue then
  667.                 game_info.mode = 'solo'
  668.             else
  669.                 game_info.mode = 'elimination'
  670.             end
  671.            
  672.             start()
  673.         end)
  674.     end
  675. end
  676.  
  677. join_prompt.Triggered:Connect(function(plr)
  678.     if not game_info.players[plr] and (game_info.playing == 0 or game_info.playing == 1) then
  679.         game_info.players[plr] = 1
  680.         run_queue()
  681.         update_queue()
  682.     end
  683. end)
Add Comment
Please, Sign In to add comment