KrYn0MoRe

Geiger Counter

Jan 28th, 2023 (edited)
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.91 KB | None | 0 0
  1. Tool0 = Instance.new("Tool")
  2. Part1 = Instance.new("Part")
  3. SurfaceGui2 = Instance.new("SurfaceGui")
  4. TextLabel3 = Instance.new("TextBox")
  5. TextLabel4 = Instance.new("TextBox")
  6. TextLabel5 = Instance.new("TextBox")
  7. TextLabel6 = Instance.new("TextBox")
  8. Tool0.Name = "Geiger Counter"
  9. Tool0.ToolTip = "Used for detecting radiation."
  10. Tool0.CanBeDropped = false
  11. Tool0.TextureId = "rbxassetid://198738758"
  12. Tool0.Parent = owner.Backpack
  13. Tool0.Grip = CFrame.new(0.643815994, 0.157236308, -0.489322126, -8.9397858e-09, -0.978862703, 0.204518422, -0.190851331, 0.200759158, 0.960870147, -0.981618941, -0.0390326045, -0.186817244)
  14. Tool0.GripForward = Vector3.new(-0.204518422, -0.960870147, 0.186817244)
  15. Tool0.GripPos = Vector3.new(0.643815994, 0.157236308, -0.489322126)
  16. Tool0.GripRight = Vector3.new(-8.9397858e-09, -0.190851331, -0.981618941)
  17. Tool0.GripUp = Vector3.new(-0.978862703, 0.200759158, -0.0390326045)
  18. Part1.Name = "Handle"
  19. Part1.Parent = Tool0
  20. Part1.CFrame = CFrame.new(-24.1300011, 0.705003858, -7.67999935, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  21. Part1.Position = Vector3.new(-24.1300011, 0.705003858, -7.67999935)
  22. Part1.Color = Color3.new(0.388235, 0.372549, 0.384314)
  23. Part1.Size = Vector3.new(1.5, 0.5, 1)
  24. Part1.BottomSurface = Enum.SurfaceType.Smooth
  25. Part1.BrickColor = BrickColor.new("Dark stone grey")
  26. Part1.CanCollide = false
  27. Part1.Material = Enum.Material.SmoothPlastic
  28. Part1.TopSurface = Enum.SurfaceType.Smooth
  29. Part1.brickColor = BrickColor.new("Dark stone grey")
  30. SurfaceGui2.Parent = Part1
  31. SurfaceGui2.Face = Enum.NormalId.Top
  32. SurfaceGui2.Adornee = Part1
  33. SurfaceGui2.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
  34. SurfaceGui2.PixelsPerStud = 75
  35. TextLabel3.Name = "title"
  36. TextLabel3.Parent = SurfaceGui2
  37. TextLabel3.Size = UDim2.new(1, 0, 0, 15)
  38. TextLabel3.BackgroundColor = BrickColor.new("White")
  39. TextLabel3.BackgroundColor3 = Color3.new(0.960784, 0.960784, 0.960784)
  40. TextLabel3.BackgroundTransparency = 1
  41. TextLabel3.BorderSizePixel = 0
  42. TextLabel3.Font = Enum.Font.ArialBold
  43. TextLabel3.Text = "Geiger RPS"
  44. TextLabel3.TextColor = BrickColor.new("Really black")
  45. TextLabel3.TextColor3 = Color3.new(0, 0, 0)
  46. TextLabel3.TextScaled = true
  47. TextLabel3.TextWrap = true
  48. TextLabel3.TextWrapped = true
  49. TextLabel4.Name = "meter"
  50. TextLabel4.Parent = SurfaceGui2
  51. TextLabel4.Position = UDim2.new(0, 0, 0.4, 0)
  52. TextLabel4.Size = UDim2.new(1, 0, 0, 30)
  53. TextLabel4.BackgroundColor = BrickColor.new("White")
  54. TextLabel4.BackgroundColor3 = Color3.new(0.960784, 0.960784, 0.960784)
  55. TextLabel4.BackgroundTransparency = 1
  56. TextLabel4.BorderSizePixel = 0
  57. TextLabel4.Font = Enum.Font.SciFi
  58. TextLabel4.Text = "0"
  59. TextLabel4.TextColor = BrickColor.new("Really black")
  60. TextLabel4.TextColor3 = Color3.new(0, 0, 0)
  61. TextLabel4.TextScaled = true
  62. TextLabel4.TextWrap = true
  63. TextLabel4.TextWrapped = true
  64. TextLabel5.Name = "player"
  65. TextLabel5.Parent = SurfaceGui2
  66. TextLabel5.Position = UDim2.new(0, 0, 0.2, 0)
  67. TextLabel5.Size = UDim2.new(1, 0, 0, 20)
  68. TextLabel5.BackgroundColor = BrickColor.new("White")
  69. TextLabel5.BackgroundColor3 = Color3.new(0.960784, 0.960784, 0.960784)
  70. TextLabel5.BackgroundTransparency = 1
  71. TextLabel5.BorderSizePixel = 0
  72. TextLabel5.Font = Enum.Font.Arial
  73. TextLabel5.Text = "NIL"
  74. TextLabel5.TextColor = BrickColor.new("Really black")
  75. TextLabel5.TextColor3 = Color3.new(0, 0, 0)
  76. TextLabel5.TextScaled = true
  77. TextLabel5.TextWrap = true
  78. TextLabel5.TextWrapped = true
  79. TextLabel6.Name = "status"
  80. TextLabel6.Parent = SurfaceGui2
  81. TextLabel6.Position = UDim2.new(0, 0, 0.75, 0)
  82. TextLabel6.Size = UDim2.new(1, 0, 0, 20)
  83. TextLabel6.BackgroundTransparency = 1
  84. TextLabel6.BorderSizePixel = 0
  85. TextLabel6.Font = Enum.Font.SciFi
  86. TextLabel6.Text = "OFF"
  87. TextLabel6.TextColor = BrickColor.new("Really red")
  88. TextLabel6.TextColor3 = Color3.new(1, 0, 0)
  89. TextLabel6.TextScaled = true
  90. TextLabel6.TextWrap = true
  91. TextLabel6.TextWrapped = true
  92.  
  93. local plr = owner
  94. local char = plr.Character
  95. local hum = char:FindFirstChildOfClass("Humanoid")
  96. local torso = char['Torso'] or char['UpperTorso']
  97. local tool = Tool0
  98. local handle = Part1
  99.  
  100. local debris = game:GetService("Debris")
  101. local tween = game:GetService("TweenService")
  102.  
  103. local using = false
  104. local equipped = false
  105. local activated = false
  106.  
  107. local turnon = Instance.new("Sound",Part1)
  108. turnon.SoundId = "rbxassetid://15666462"
  109. turnon.EmitterSize = 1
  110. turnon.Volume = 5
  111.  
  112. local counter = Instance.new("Sound",Part1)
  113. counter.Looped = true
  114. counter.SoundId = "rbxassetid://145214482"
  115. counter.EmitterSize = 1
  116. counter.Volume = 4
  117.  
  118. local switch = Instance.new("Sound",Part1)
  119. switch.SoundId = "rbxassetid://190126363"
  120. switch.EmitterSize = 1
  121. switch.Volume = 5
  122.  
  123. tool.Equipped:Connect(function()
  124.     equipped = true
  125.     turnon:Play()
  126.     if activated then
  127.         counter:Resume()
  128.     end
  129. end)
  130. tool.Unequipped:Connect(function()
  131.     equipped = false
  132.     turnon:Stop()
  133.     counter:Stop()
  134.     switch:Stop()
  135. end)
  136.  
  137. Tool0.Activated:Connect(function()
  138.     switch:Play()
  139.     if equipped then
  140.         activated = not activated
  141.     end
  142.     if activated then
  143.         counter:Play()
  144.         TextLabel6.Text = "ON"
  145.         TextLabel6.TextColor3 = Color3.new(44/255, 255/255, 12/255)
  146.     elseif not activated then
  147.         counter:Stop()
  148.         TextLabel6.Text = "OFF"
  149.         TextLabel6.TextColor3 = Color3.new(1, 0, 0)
  150.     end
  151. end)
  152.  
  153. function FindNearestHead(Position, Distance, SinglePlayer)
  154.     if SinglePlayer then
  155.         return (SinglePlayer.Torso.CFrame.p - Position).magnitude < Distance
  156.     end
  157.     local List = {}
  158.     local closest = math.huge
  159.     for i, v in pairs(workspace:GetChildren()) do
  160.         if v:IsA("Model") then
  161.             if v:FindFirstChild("Head") then
  162.                 local dist = (v.Head.Position - Position).Magnitude
  163.                 if (v.Head.Position - Position).Magnitude <= Distance then
  164.                     table.insert(List, dist, v)
  165.                     if closest > dist then
  166.                         closest = dist
  167.                     end
  168.                 end
  169.             end
  170.         end
  171.     end
  172.     return List
  173. end
  174.  
  175. if not _G['rad_char_data'] then
  176.     _G['rad_char_data'] = {}
  177. end
  178.  
  179. while task.wait(1) do
  180.     local data = _G['rad_char_data'] or {}
  181.     if equipped and activated then
  182.         local result = 0
  183.         local infector = 'NIL'
  184.         local list = FindNearestHead(torso.CFrame.Position,25)
  185.         local tchar
  186.         local pdata
  187.         for i,v in pairs(list) do
  188.             if data[v] and data[v].gy > 0.1 then
  189.                 tchar = v
  190.                 pdata = data[v]
  191.                 break
  192.             end
  193.         end
  194.         local default_vol = 0.5
  195.         local default_speed = 0.5
  196.         local max_gy = 20
  197.         if pdata then
  198.             local gy = pdata.gy
  199.             result = math.round(gy*10)/10
  200.             infector = tchar.Name
  201.             local max = 15
  202.             counter.PlaybackSpeed = default_speed + math.clamp(gy/max,0,1)
  203.             counter.Volume = default_vol + math.clamp(gy/max,0,1)
  204.         else
  205.             counter.PlaybackSpeed = default_speed
  206.             counter.Volume = default_vol
  207.         end
  208.         if result > 0.1 then
  209.             counter:Resume()
  210.            
  211.             if result > max_gy then
  212.                 result = max_gy .. "+"
  213.             end
  214.             TextLabel4.Text = result
  215.             TextLabel5.Text = infector
  216.         elseif 0 >= result then
  217.             counter:Stop()
  218.  
  219.             TextLabel4.Text = "0"
  220.             TextLabel5.Text = "NIL"
  221.         end
  222.     else
  223.         TextLabel4.Text = "0"
  224.         TextLabel5.Text = "NIL"
  225.         counter:Stop()
  226.     end
  227. end
Add Comment
Please, Sign In to add comment