Advertisement
KrYn0MoRe

aim test speedrun

Jun 9th, 2020
1,283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.28 KB | None | 0 0
  1. local board = Instance.new("Part")
  2. Part1 = Instance.new("Part")
  3. SurfaceGui2 = Instance.new("SurfaceGui")
  4. board.Name = "Board"
  5. board.Parent = script
  6. board.CFrame = CFrame.new(37.7500038, 5.49999905, -49.0300102, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  7. board.Position = Vector3.new(37.7500038, 5.49999905, -49.0300102)
  8. board.Color = Color3.new(0.972549, 0.972549, 0.972549)
  9. board.Size = Vector3.new(17, 11, 0.5)
  10. board.Anchored = true
  11. board.BottomSurface = Enum.SurfaceType.Smooth
  12. board.BrickColor = BrickColor.new("Institutional white")
  13. board.Locked = true
  14. board.Material = Enum.Material.SmoothPlastic
  15. board.TopSurface = Enum.SurfaceType.Smooth
  16. board.brickColor = BrickColor.new("Institutional white")
  17. Part1.Name = "Score"
  18. Part1.Parent = script
  19. Part1.CFrame = CFrame.new(37.7500038, 12.5048256, -49.0300102, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  20. Part1.Position = Vector3.new(37.7500038, 12.5048256, -49.0300102)
  21. Part1.Color = Color3.new(0.768627, 0.156863, 0.109804)
  22. Part1.Size = Vector3.new(17, 3, 0.5)
  23. Part1.Anchored = true
  24. Part1.BottomSurface = Enum.SurfaceType.Smooth
  25. Part1.BrickColor = BrickColor.new("Bright red")
  26. Part1.Locked = true
  27. Part1.Material = Enum.Material.SmoothPlastic
  28. Part1.TopSurface = Enum.SurfaceType.Smooth
  29. Part1.brickColor = BrickColor.new("Bright red")
  30. SurfaceGui2.Parent = Part1
  31. SurfaceGui2.LightInfluence = 1
  32. SurfaceGui2.Face = Enum.NormalId.Back
  33. SurfaceGui2.ClipsDescendants = true
  34. SurfaceGui2.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  35. SurfaceGui2.Adornee = Part1
  36. score_t = Instance.new("TextBox")
  37. time_t = Instance.new("TextBox")
  38. score2_t = Instance.new("TextBox")
  39. player_t = Instance.new("TextBox")
  40. score_t.Name = "Score"
  41. score_t.Parent = SurfaceGui2
  42. score_t.Position = UDim2.new(0, 0, 0.5, 0)
  43. score_t.Size = UDim2.new(0.5, 0, 0.5, 0)
  44. score_t.BackgroundColor = BrickColor.new("Institutional white")
  45. score_t.BackgroundColor3 = Color3.new(1, 1, 1)
  46. score_t.BackgroundTransparency = 1
  47. score_t.Font = Enum.Font.SourceSans
  48. score_t.FontSize = Enum.FontSize.Size14
  49. score_t.Text = "Score: "
  50. score_t.TextColor = BrickColor.new("Institutional white")
  51. score_t.TextColor3 = Color3.new(1, 1, 1)
  52. score_t.TextScaled = true
  53. score_t.TextSize = 14
  54. score_t.TextStrokeTransparency = 0
  55. score_t.TextWrap = true
  56. score_t.TextWrapped = true
  57. time_t.Name = "Time"
  58. time_t.Parent = SurfaceGui2
  59. time_t.Position = UDim2.new(0.5, 0, 0.5, 0)
  60. time_t.Size = UDim2.new(0.5, 0, 0.5, 0)
  61. time_t.BackgroundColor = BrickColor.new("Institutional white")
  62. time_t.BackgroundColor3 = Color3.new(1, 1, 1)
  63. time_t.BackgroundTransparency = 1
  64. time_t.Font = Enum.Font.SourceSans
  65. time_t.FontSize = Enum.FontSize.Size14
  66. time_t.Text = "Time: "
  67. time_t.TextColor = BrickColor.new("Institutional white")
  68. time_t.TextColor3 = Color3.new(1, 1, 1)
  69. time_t.TextScaled = true
  70. time_t.TextSize = 14
  71. time_t.TextStrokeTransparency = 0
  72. time_t.TextWrap = true
  73. time_t.TextWrapped = true
  74. score2_t.Name = "Score2"
  75. score2_t.Parent = SurfaceGui2
  76. score2_t.Position = UDim2.new(0.5, 0, 0.3, 0)
  77. score2_t.Size = UDim2.new(0.5, 0, 0.3, 0)
  78. score2_t.BackgroundColor = BrickColor.new("Institutional white")
  79. score2_t.BackgroundColor3 = Color3.new(1, 1, 1)
  80. score2_t.BackgroundTransparency = 1
  81. score2_t.Font = Enum.Font.SourceSans
  82. score2_t.FontSize = Enum.FontSize.Size14
  83. score2_t.Text = "H/M*T Score: "
  84. score2_t.TextColor = BrickColor.new("Institutional white")
  85. score2_t.TextColor3 = Color3.new(1, 1, 1)
  86. score2_t.TextScaled = true
  87. score2_t.TextSize = 14
  88. score2_t.TextStrokeTransparency = 0
  89. score2_t.TextWrap = true
  90. score2_t.TextWrapped = true
  91. player_t.Name = "User"
  92. player_t.Parent = SurfaceGui2
  93. player_t.Size = UDim2.new(0.5, 0, 0.3, 0)
  94. player_t.Position = UDim2.new(0, 0, 0.3, 0)
  95. player_t.BackgroundColor = BrickColor.new("Institutional white")
  96. player_t.BackgroundColor3 = Color3.new(1, 1, 1)
  97. player_t.BackgroundTransparency = 1
  98. player_t.Font = Enum.Font.SourceSans
  99. player_t.FontSize = Enum.FontSize.Size14
  100. player_t.Text = "Player"
  101. player_t.TextColor = BrickColor.new("Institutional white")
  102. player_t.TextColor3 = Color3.new(1, 1, 1)
  103. player_t.TextScaled = true
  104. player_t.TextSize = 14
  105. player_t.TextStrokeTransparency = 0
  106. player_t.TextWrap = true
  107. player_t.TextWrapped = true
  108. barrier = Instance.new("Part")
  109. barrier.Name = "Barrier"
  110. barrier.Parent = script
  111. barrier.CFrame = CFrame.new(37.7500038, 7.49999905, -40.0300102, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  112. barrier.Position = Vector3.new(37.7500038, 7.49999905, -40.0300102)
  113. barrier.Color = Color3.new(0, 1, 1)
  114. barrier.Transparency = 0.80000001192093
  115. barrier.Size = Vector3.new(21, 15, 20.5)
  116. barrier.Anchored = true
  117. barrier.BottomSurface = Enum.SurfaceType.Smooth
  118. barrier.BrickColor = BrickColor.new("Toothpaste")
  119. barrier.Locked = true
  120. barrier.Material = Enum.Material.SmoothPlastic
  121. barrier.TopSurface = Enum.SurfaceType.Smooth
  122. barrier.brickColor = BrickColor.new("Toothpaste")
  123. --
  124. invite = Instance.new("TextBox")
  125. invite.Name = "invite"
  126. invite.Parent = SurfaceGui2
  127. invite.Position = UDim2.new(0, 0, 0, 0)
  128. invite.Size = UDim2.new(1, 0, 0.3, 0)
  129. invite.BackgroundColor = BrickColor.new("Institutional white")
  130. invite.BackgroundColor3 = Color3.new(1, 1, 1)
  131. invite.BackgroundTransparency = 1
  132. invite.Font = Enum.Font.SourceSans
  133. invite.FontSize = Enum.FontSize.Size14
  134. invite.Text = "Submit scores at: discord.gg/7VB6kAQ"
  135. invite.TextColor = BrickColor.new("Really red")
  136. invite.TextColor3 = Color3.fromRGB(42, 255, 231)
  137. invite.TextScaled = true
  138. invite.TextSize = 14
  139. invite.TextStrokeTransparency = 0
  140. invite.TextWrap = true
  141. invite.TextWrapped = true
  142.  
  143. for i,v in pairs(script:GetChildren()) do
  144.     if v:IsA("BasePart") and v ~= board then
  145.         v.Anchored = false
  146.         local weld = Instance.new("Weld")
  147.         weld.Part0 = board
  148.         weld.Part1 = v
  149.         weld.C0 = board.CFrame:Inverse()
  150.         weld.C1 = v.CFrame:Inverse()
  151.         weld.Parent = v
  152.     end
  153. end
  154.  
  155. local plr = owner
  156. local char = plr.Character
  157. if char then else warn("Character not loaded. Re-run the script.") return end
  158. local root = char:FindFirstChild("Torso") or char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("Head")
  159.  
  160. board.CFrame = CFrame.new(root.Position)*CFrame.new(0,5.5,0)
  161.  
  162. local S = 1
  163.  
  164. local ding = Instance.new("Sound")
  165. ding.SoundId = 'rbxassetid://'
  166. ding.Parent = board
  167.  
  168. local count = 0
  169. local playing = false
  170. local targets = {}
  171. local score = {
  172.     hit = 0,
  173.     miss = 0,
  174. }
  175.  
  176. function check_near(p)
  177.     local close = false
  178.     for _,hit in pairs(targets) do
  179.         if hit ~= p and (S*2) >= (p.Position-hit.Position).Magnitude then
  180.             close = true
  181.         end
  182.     end
  183.     return close
  184. end
  185.  
  186. function create_target()
  187.     local _PX,_PY = math.random(1,board.Size.X),math.random(1,board.Size.Y)
  188.     local pos = (board.Position+Vector3.new(-(board.Size.X/2),(board.Size.Y/2),0))-Vector3.new(-(_PX-S/2),(_PY-S/2),0)
  189.     local target = Instance.new("Part")
  190.     target.Position = pos+Vector3.new(0,0,S/2)
  191.     target.Color = Color3.new(0,0,0)
  192.     target.Size = Vector3.new(S,S,S/2)
  193.     target.Anchored = true
  194.     target.Locked = true
  195.     target.Material = Enum.Material.SmoothPlastic
  196.     target.Parent = script
  197.     local c = check_near(target)
  198.     if c or not playing then
  199.         target:Destroy()
  200.     else
  201.         table.insert(targets,1,target)
  202.     end
  203. end
  204.  
  205. function hit_target(p)
  206.     local found = false
  207.     if p then else score.miss = score.miss + 1; score_t.Text = 'Score: ' .. score.hit-score.miss; return; end;
  208.     for i,v in pairs(targets) do
  209.         if v == p then
  210.             found = true;
  211.             table.remove(targets,i);
  212.         end;
  213.     end;
  214.     if found then
  215.         p:Destroy()
  216.         --ding:Play()
  217.         score.hit = score.hit + 1
  218.     else
  219.         score.miss = score.miss + 1
  220.     end
  221.     score_t.Text = 'Score: ' .. score.hit-score.miss
  222.     score2_t.Text = 'H/M*H Score: ' .. (score.hit/score.miss*score.hit)-((score.hit/score.miss*score.hit)%0.001)
  223. end
  224.  
  225. local remote = Instance.new("RemoteEvent")
  226. remote.Parent = plr['PlayerGui']
  227. local bval = Instance.new("ObjectValue")
  228. bval.Name = 'board'
  229. bval.Value = board
  230. bval.Parent = remote
  231.  
  232. remote.OnServerEvent:Connect(function(lplr,hit)
  233.     if (plr == lplr) and playing then
  234.         hit_target(hit)
  235.     end
  236. end)
  237.  
  238. NLS([[
  239. local plr = game:GetService("Players").LocalPlayer
  240. local mouse = plr:GetMouse()
  241. local camera = workspace.CurrentCamera
  242. local remote = script.Parent
  243. local board = remote:WaitForChild("board").Value
  244.  
  245. mouse.Button1Down:Connect(function()
  246.     remote:FireServer(mouse.Target)
  247. end)
  248.  
  249. game:GetService("RunService").RenderStepped:Connect(function()
  250.     camera.CameraSubject = board
  251.     camera.CFrame = board.CFrame*CFrame.new(0,0,15)
  252. end)
  253. ]],remote)
  254.  
  255. function stop()
  256.     spawn(function()
  257.         for i = 10,0,-1 do
  258.             time_t.Text = 'Intermission: ' .. i
  259.             wait(1)
  260.         end
  261.         for i,v in pairs(targets) do if v then v:Destroy(); table.remove(targets,i); end; end;
  262.         score.hit = 0
  263.         score.miss = 0
  264.         start()
  265.     end)
  266. end
  267.  
  268. function setup_time()
  269.     count = 30
  270.     spawn(function()
  271.         while playing do
  272.             if 0 >= count then
  273.                 playing = false
  274.                 stop()
  275.                 return
  276.             end
  277.             count = count - 1
  278.             time_t.Text = 'Time: ' .. count
  279.             wait(1)
  280.         end
  281.     end)
  282. end
  283.  
  284. function setup_targets()
  285.     spawn(function()
  286.         while playing do
  287.             if 5 > #targets and playing then
  288.                 create_target()
  289.             end
  290.             wait()
  291.         end
  292.     end)
  293. end
  294.  
  295. function start()
  296.     playing = true
  297.     setup_targets()
  298.     setup_time()
  299. end
  300.  
  301. SurfaceGui2.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
  302. SurfaceGui2.PixelsPerStud = 50
  303. player_t.Text = plr.Name
  304.  
  305. game:GetService("RunService").Stepped:Connect(function()
  306.     pcall(function()
  307.         for i,v in pairs(plr.Character:GetChildren()) do
  308.             if v:IsA("BasePart") or v:IsA("UnionOperation") or v:IsA("Sound") or v:IsA("Script") or v:IsA("LocalScript") or v:IsA("BillboardGui") then
  309.                 v:Destroy()
  310.             end
  311.         end
  312.     end)
  313. end)
  314.  
  315. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement