Advertisement
XZTablets

Roblox Rainbow Gui

Jul 9th, 2019
1,109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. local rainbow = {}
  2. local size = 64
  3. local gui = script.Parent
  4.  
  5. function color3FromHex(n)
  6. n = math.floor(n)
  7. local b = n % 256
  8. local g = ((n-b)/256)%256
  9. local r = (n-b-g*256)/65536
  10. return Color3.new(r/255,g/255,b/255)
  11. end
  12.  
  13. local function numberToString(x)
  14. local options = {'F', 'E', 'D', 'C', 'B', 'A'}
  15. return options[16-x]
  16. end
  17.  
  18. local function hexOf(i)
  19. local base = math.floor(i / 16)
  20. local remainder = (i - (base * 16))
  21. if base >= 10 then
  22. base = numberToString(base)
  23. end
  24. if remainder >= 10 then
  25. remainder = numberToString(remainder)
  26. end
  27. return (base..remainder)
  28. end
  29.  
  30. local function sin_to_hex(i, shift)
  31. local sin = math.sin(math.pi / size * 2 * i + shift)
  32. local int = math.floor(sin * 127) + 128
  33. local hex = hexOf(int)
  34. return hex
  35. end
  36.  
  37. for i = 0, size do
  38. local red = sin_to_hex(i, 0 * math.pi * 2/3)
  39. local blue = sin_to_hex(i, 1 * math.pi * 2/3)
  40. local green = sin_to_hex(i, 2 * math.pi * 2/3)
  41. local result = (red..green..blue)
  42. table.insert(rainbow, result)
  43. end
  44.  
  45. local x = 0
  46. local y = 0
  47.  
  48. for i = 1, #rainbow do
  49. local frame = Instance.new("Frame")
  50. frame.Parent = gui
  51. frame.Size = UDim2.new(0,20,0,20)
  52. frame.BorderSizePixel = 0
  53. frame.BackgroundColor3 = color3FromHex("0x"..rainbow[i])
  54. x = math.random(20, 60)
  55. y = math.random(60, 200)
  56. frame.Position = UDim2.new(0,x,0,y)
  57. end
  58.  
  59. while wait() do
  60. for i,v in pairs(gui:GetChildren()) do
  61. if v.ClassName == "Frame" then
  62. x = math.random(20, 60)
  63. y = math.random(60, 200)
  64. t = math.floor((math.random()*100)-0.5)
  65. v.Position = UDim2.new(0,x,0,y)
  66. v.BackgroundTransparency = t
  67. end
  68. end
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement