Advertisement
KrYn0MoRe

ionizing radiation

May 23rd, 2021 (edited)
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.56 KB | None | 0 0
  1. mas = script
  2. Part0 = Instance.new("Part")
  3. Part1 = Instance.new("Part")
  4. Part2 = Instance.new("Part")
  5. Part0.Parent = mas
  6. Part0.CFrame = CFrame.new(-13.1700001, 3.50000381, 20.1999989, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  7. Part0.Position = Vector3.new(-13.170000076294, 3.5000038146973, 20.199998855591)
  8. Part0.Size = Vector3.new(2, 7, 13)
  9. Part0.Anchored = true
  10. Part0.BottomSurface = Enum.SurfaceType.Smooth
  11. Part0.Material = Enum.Material.DiamondPlate
  12. Part0.TopSurface = Enum.SurfaceType.Smooth
  13. Part1.Parent = mas
  14. Part1.CFrame = CFrame.new(-20.1700001, 3.50000381, 14.6999989, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  15. Part1.Position = Vector3.new(-20.170000076294, 3.5000038146973, 14.699998855591)
  16. Part1.Size = Vector3.new(16, 7, 2)
  17. Part1.Anchored = true
  18. Part1.BottomSurface = Enum.SurfaceType.Smooth
  19. Part1.Material = Enum.Material.DiamondPlate
  20. Part1.TopSurface = Enum.SurfaceType.Smooth
  21. Part2.Parent = mas
  22. Part2.Name = 'uranium'
  23. Part2.CFrame = CFrame.new(-21.0336342, 0.124483503, 21.6262875, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  24. Part2.Position = Vector3.new(-21.033634185791, 0.12448350340128, 21.626287460327)
  25. Part2.Color = Color3.new(0, 1, 0)
  26. Part2.Size = Vector3.new(7.7983164787292, 0.24896498024464, 6.8297309875488)
  27. Part2.Anchored = true
  28. Part2.BottomSurface = Enum.SurfaceType.Smooth
  29. Part2.BrickColor = BrickColor.new("Lime green")
  30. Part2.CanCollide = false
  31. Part2.Material = Enum.Material.Neon
  32. Part2.TopSurface = Enum.SurfaceType.Smooth
  33. Part2.brickColor = BrickColor.new("Lime green")
  34.  
  35. for i,v in pairs(mas:GetChildren()) do
  36.     v.CFrame = v.CFrame*CFrame.new(-10,0,0)
  37. end
  38.  
  39. local doses = {
  40.     fatal = 10,
  41.     stage2 = 6,
  42.     stage1 = 2,
  43.     normal = 1,
  44. }
  45.  
  46. local gy_per_rad = 0.01
  47. if not _G['rad_char_data'] then
  48.     _G['rad_char_data'] = {}
  49. end
  50. local data = _G['rad_char_data'] or {}
  51. local rads = {}
  52. local pukes = {1067194716,1067195344,1067195040}
  53.  
  54. function get_gy(n)
  55.     return n*gy_per_rad
  56. end
  57.  
  58. for i,v in pairs(script:GetChildren()) do
  59.     if v.Name == 'uranium' then
  60.         table.insert(rads,1,v)
  61.     end
  62. end
  63.  
  64. function raycast(Pos, Dir, Max, Ignore)
  65.     local rayparams = RaycastParams.new()
  66.     rayparams.FilterType = Enum.RaycastFilterType.Blacklist
  67.     rayparams.FilterDescendantsInstances = Ignore
  68.     rayparams.IgnoreWater = true
  69.     return workspace:Raycast(Pos, Dir * (Max or 999.999), rayparams)
  70. end
  71.  
  72. local st = os.clock()
  73. game:GetService("RunService").Stepped:Connect(function()
  74.     local delta = os.clock()-st
  75.     st = os.clock()
  76.    
  77.     local ignore = {
  78.         unpack(rads)
  79.     }
  80.  
  81.     for _,con in pairs(rads) do
  82.         for _,char in pairs(workspace:GetChildren()) do
  83.             if char then
  84.                 if not data[char] then
  85.                     data[char] = {
  86.                         gy = 0,
  87.                         last_check = 0,
  88.                     }
  89.                 end
  90.                 local root = char:FindFirstChild("HumanoidRootPart")
  91.                 local hum = char:FindFirstChildOfClass("Humanoid")
  92.                 if root and hum then else continue end
  93.                 local cdata = data[char]
  94.                 if cdata and hum and hum.Health > 0 and root then
  95.                     local pos = con.Position+Vector3.new(0,1,0)
  96.                     local dir = (root.Position-pos).Unit
  97.                     local result = raycast(pos,dir,nil,ignore)
  98.  
  99.                     if result then
  100.                         local obj,hitpos = result.Instance,result.Position
  101.                         if obj and obj:IsDescendantOf(char) then
  102.                             local dist = (hitpos-pos).Magnitude
  103.                             data[char].gy += get_gy(25)/(dist^2)
  104.                             data[char].gy *= 1+(delta/10)/(dist^2)
  105.                         elseif data[char].gy > 0 then
  106.                             if data[char].gy > 5 then
  107.                                 data[char].gy -= get_gy(10)*delta
  108.                                 data[char].gy -= data[char].gy*(delta/20)
  109.                             else
  110.                                 data[char].gy -= get_gy(5)*delta
  111.                                 data[char].gy -= data[char].gy*(delta/20)
  112.                             end
  113.                         end
  114.                     end
  115.                     if 0 > data[char].gy then
  116.                         data[char].gy = 0
  117.                     end
  118.                    
  119.                     local dmg = cdata.gy/150
  120.                     if cdata.gy >= doses.normal then
  121.                         hum:TakeDamage(dmg)
  122.                     end
  123.                    
  124.                     if cdata.gy >= doses.stage2 and os.clock()-cdata.last_check >= 10 then
  125.                         data[char].last_check = os.clock()
  126.                         local s = Instance.new("Sound")
  127.                         s.SoundId = 'rbxassetid://' .. pukes[math.random(#pukes)]
  128.                         s.Volume = 0.5
  129.                         s.Parent = root
  130.                         s:Play()
  131.                         game:GetService("Debris"):AddItem(s,3)
  132.                     elseif cdata.gy >= doses.stage1 and doses.stage2 > cdata.gy and os.clock()-cdata.last_check >= 5 then
  133.                         data[char].last_check = os.clock()
  134.                         local s = Instance.new("Sound")
  135.                         s.SoundId = 'rbxassetid://328460122'
  136.                         s.Volume = 0.5
  137.                         s.Parent = root
  138.                         s:Play()
  139.                         game:GetService("Debris"):AddItem(s,3)
  140.                     end
  141.                 end
  142.             end
  143.         end
  144.     end
  145.     if not _G['rad_char_data'] then
  146.         _G['rad_char_data'] = {}
  147.     end
  148.     for i,v in pairs(data) do
  149.         _G['rad_char_data'][i] = v
  150.     end
  151. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement