Advertisement
xOmqDarryl

Untitled

Dec 9th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. local cam=workspace.CurrentCamera
  2. local screen_size=Vector2.new(0,0)
  3. local maxdist=500 -- Maximum distance from where parts should be visible
  4. local update=10 -- In seconds
  5. local oldt=tick()
  6. local gui=game.StarterGui.ScreenGui
  7. screen_size=Vector2.new(gui.AbsoluteSize.x,gui.AbsoluteSize.y)
  8.  
  9. local function pixel2stud(pix)
  10. return pix * 2.54 / 96
  11. end
  12.  
  13. local objects,trans={},{}
  14. function Get(par,class)
  15. local cl=class;
  16. local chs=par:GetChildren()
  17. for i=1,#chs do
  18. if chs[i]:IsA(class) and not chs[i].Parent:findFirstChild"Humanoid" then
  19. table.insert(objects,chs[i])
  20. table.insert(trans,chs[i].Transparency)
  21. end
  22. Get(chs[i],cl)
  23. end
  24. return objects;
  25. end
  26. gt=Get(workspace,"BasePart")
  27.  
  28. gui.Changed:connect(function(w)
  29. if w=="AbsoluteSize" then
  30. screen_size=Vector2.new(gui.AbsoluteSize.x,gui.AbsoluteSize.y)
  31. end
  32. end)
  33.  
  34. while true do
  35. local mid=cam.CoordinateFrame*CFrame.new(0,0,-maxdist)
  36. --local region=Region3.new(Vector3.new(bottom_left.p.x,bottom_left.p.y,bottom_left.p.z),Vector3.new(top_far_right.p.x,top_right.p.y,top_far_right.p.z))
  37. --local parts = workspace:FindPartsInRegion3(region)
  38. if tick()>oldt+update then
  39. oldt=tick()
  40. objects={}
  41. gt=Get(workspace,"BasePart")
  42. end
  43. for i=1,#gt do
  44. --if (gt[i].Position-cam.CoordinateFrame*CFrame.new(0,0,(maxdist/rays)*path).p).magnitude<=pixel2stud(math.max(screen_size.x,screen_size.y))*path then
  45. if (gt[i].Position-mid.p).magnitude<=maxdist then
  46. gt[i].Transparency=trans[i]
  47. else
  48. gt[i].Transparency=1
  49. end
  50. end
  51. wait()
  52. end
  53.  
  54. --mediafire
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement