Advertisement
Delros12

Eyeball Script

May 26th, 2018 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.01 KB | None | 0 0
  1. -- Chat color algorithm...
  2. local CHAT_COLORS =
  3. {
  4.     Color3.new(253/255, 41/255, 67/255), -- BrickColor.new("Bright red").Color,
  5.     Color3.new(1/255, 162/255, 255/255), -- BrickColor.new("Bright blue").Color,
  6.     Color3.new(2/255, 184/255, 87/255), -- BrickColor.new("Earth green").Color,
  7.     BrickColor.new("Bright violet").Color,
  8.     BrickColor.new("Bright orange").Color,
  9.     BrickColor.new("Bright yellow").Color,
  10.     BrickColor.new("Light reddish violet").Color,
  11.     BrickColor.new("Brick yellow").Color,
  12. }
  13.  
  14. function GetNameValue(pName)
  15.     local value = 0
  16.     for index = 1, #pName do
  17.         local cValue = string.byte(string.sub(pName, index, index))
  18.         local reverseIndex = #pName - index + 1
  19.         if #pName%2 == 1 then
  20.             reverseIndex = reverseIndex - 1
  21.         end
  22.         if reverseIndex%4 >= 2 then
  23.             cValue = -cValue
  24.         end
  25.         value = value + cValue
  26.     end
  27.     return value
  28. end
  29. --
  30.  
  31. local player = game.Players.LocalPlayer
  32. local camera = workspace.Camera
  33. local mouse = player:GetMouse()
  34. local RS = game:GetService("RunService").RenderStepped
  35.  
  36. local char = player.Character
  37. if char then
  38.     char:Destroy()
  39. end
  40.  
  41. local color = CHAT_COLORS[(GetNameValue(player.Name) % #CHAT_COLORS) + 1]
  42.  
  43. function makeEyeballPart(part, parent)
  44.     if part == "base" then
  45.         local base = Instance.new("Part", parent)
  46.         base.Name = "base"
  47.         base.Color = color
  48.         base.Transparency = 0.275
  49.         base.Material = "SmoothPlastic"
  50.         base.Size = Vector3.new(1.5, 1.5, 1.5)
  51.         base.Shape = 0
  52.         base.CanCollide = false
  53.         base.Anchored = true
  54.         base.LocalTransparencyModifier = 10
  55.        
  56.         local nameBillboard = Instance.new("BillboardGui", base)
  57.         nameBillboard.LightInfluence = 0
  58.         nameBillboard.Size = UDim2.new(0, 105, 0, 105)
  59.         nameBillboard.AlwaysOnTop = true
  60.        
  61.         local playerName = Instance.new("TextLabel", nameBillboard)
  62.         playerName.Name = "PlayerName"
  63.         playerName.Size = UDim2.new(0, 2000, 0, 5)
  64.         playerName.Position = UDim2.new(0, -950, 0, -145)
  65.         playerName.BackgroundTransparency = 1
  66.         playerName.Font = "ArialBold"
  67.         playerName.TextSize = 13
  68.         playerName.TextColor3 = Color3.new(1, 1, 1)
  69.         playerName.TextStrokeTransparency = 0
  70.         playerName.TextStrokeColor3 = Color3.new(0, 0, 0)
  71.         playerName.TextWrapped = true
  72.         playerName.Text = player.Name
  73.        
  74.         return base
  75.     elseif part == "arrow" then
  76.         local arrow = Instance.new("Part", parent)
  77.         arrow.Name = "arrow"
  78.         arrow.Color = color
  79.         arrow.Transparency = 0.275
  80.         arrow.Material = "SmoothPlastic"
  81.         arrow.Size = Vector3.new(0.3, 0.6, 0.3)
  82.         arrow.CanCollide = false
  83.         arrow.Anchored = true
  84.         arrow.LocalTransparencyModifier = 10
  85.        
  86.         local arrowMesh = Instance.new("SpecialMesh", arrow)
  87.         arrowMesh.MeshId = "rbxassetid://785967755"
  88.         arrowMesh.Scale = Vector3.new(0.006, 0.012, 0.006)
  89.        
  90.         return arrow
  91.     elseif part == "line" then
  92.         local line = Instance.new("Part", parent)
  93.         line.Name = "line"
  94.         line.Color = color
  95.         line.Transparency = 0.275
  96.         line.Material = "SmoothPlastic"
  97.         line.Size = Vector3.new(2.25, 0.125, 0.125)
  98.         line.Shape = 2
  99.         line.CanCollide = false
  100.         line.Anchored = true
  101.         line.LocalTransparencyModifier = 10
  102.        
  103.         return line
  104.     end
  105. end
  106.  
  107. -- make eyeball model
  108. local eyeBall = Instance.new("Model", workspace)
  109. eyeBall.Name = player.Name .. "'s Eyeball"
  110. mouse.TargetFilter = eyeBall
  111.  
  112. local base = makeEyeballPart("base", eyeBall)
  113. local arrow = makeEyeballPart("arrow", eyeBall)
  114. local line = makeEyeballPart("line", eyeBall)
  115.  
  116. -- undestroyable
  117. eyeBall.ChildRemoved:connect(function(part)
  118.     if part.Name == "base" then
  119.         base = makeEyeballPart("base", eyeBall)
  120.     elseif part.Name == "arrow" then
  121.         arrow = makeEyeballPart("arrow", eyeBall)
  122.     elseif part.Name == "line" then
  123.         line = makeEyeballPart("line", eyeBall)
  124.     end
  125. end)
  126. workspace.ChildRemoved:connect(function(part)
  127.     if part.Name == player.Name .. "'s Eyeball" then
  128.         local eyeBall = Instance.new("Model", workspace)
  129.         eyeBall.Name = player.Name .. "'s Eyeball"
  130.         mouse.TargetFilter = eyeBall
  131.        
  132.         base = makeEyeballPart("base", eyeBall)
  133.         arrow = makeEyeballPart("arrow", eyeBall)
  134.         line = makeEyeballPart("line", eyeBall)
  135.        
  136.         eyeBall.ChildRemoved:connect(function(part)
  137.             if part.Name == "base" then
  138.                 base = makeEyeballPart("base", eyeBall)
  139.             elseif part.Name == "arrow" then
  140.                 arrow = makeEyeballPart("arrow", eyeBall)
  141.             elseif part.Name == "line" then
  142.                 line = makeEyeballPart("line", eyeBall)
  143.             end
  144.         end)
  145.     end
  146. end)
  147. --
  148.  
  149. local focus = Instance.new("Part", camera)
  150. focus.Anchored = true
  151. focus.Transparency = 1
  152. focus.CanCollide = false
  153. focus.Size = Vector3.new(0, 0, 0)
  154. focus.CFrame = camera.CFrame
  155. focus.Shape = 0
  156.  
  157. camera.CameraSubject = focus
  158. camera.CameraType = Enum.CameraType.Watch
  159.  
  160. local keyW = false
  161. local keyA = false
  162. local keyS = false
  163. local keyD = false
  164. local keyQ = false
  165. local keyE = false
  166. local keyShift = false
  167.  
  168. local settings = {
  169.     speedIncrement = 0.005,
  170.     speed = 0.5, -- default is 1
  171.     slowSpeed = 0.2,
  172.     collidable = false
  173. }
  174. if settings.collidable == true then
  175.     base.CanCollide = true
  176.     arrow.CanCollide = true
  177.     line.CanCollide = true
  178. end
  179.  
  180. local speed = settings.speed
  181.  
  182. local plrBillboard = Instance.new("BillboardGui", camera)
  183. plrBillboard.LightInfluence = 0
  184. plrBillboard.Size = UDim2.new(0, 105, 0, 105)
  185. plrBillboard.AlwaysOnTop = true
  186. plrBillboard.Adornee = nil
  187.        
  188. local plrName = Instance.new("TextLabel", plrBillboard)
  189. plrName.Name = "PlayerName"
  190. plrName.Size = UDim2.new(0, 2000, 0, 5)
  191. plrName.Position = UDim2.new(0, -950, 0, 45)
  192. plrName.BackgroundTransparency = 1
  193. plrName.Font = "ArialBold"
  194. plrName.TextSize = 13
  195. plrName.TextColor3 = Color3.new(1, 1, 1)
  196. plrName.TextStrokeTransparency = 0
  197. plrName.TextStrokeColor3 = Color3.new(0, 0, 0)
  198. plrName.TextWrapped = true
  199. plrName.Text = ""
  200. function Update()
  201.     if keyW == true or keyA == true or keyS == true or keyD == true
  202.         or keyQ == true or keyE == true then
  203.         speed = speed + settings.speedIncrement
  204.     end
  205.     base.CFrame = camera.CFrame
  206.     line.CFrame = camera.CFrame * CFrame.Angles(0, math.rad(90), 0)
  207.     arrow.CFrame = line.CFrame * CFrame.new(line.Size.X/2 + arrow.Size.Y/2, 0, 0) * CFrame.Angles(0, 0, math.rad(-90))
  208.  
  209.     plrBillboard.Adornee = nil
  210.     plrName.Text = ""  
  211.    
  212.     local target = mouse.Target
  213.     if target then
  214.         local hum = target.Parent:FindFirstChild("Humanoid")
  215.         if hum then
  216.             plrBillboard.Adornee = target.Parent.Head
  217.             plrName.Text = target.Parent.Name
  218.         end
  219.     end
  220. end
  221.  
  222. game:GetService("RunService").RenderStepped:connect(Update)
  223.  
  224. mouse.KeyDown:connect(function(key)
  225.     local tempSpeed = speed
  226.     if string.byte(key) == 47 or string.byte(key) == 48 then
  227.         keyShift = true
  228.     end
  229.     if keyShift == true then
  230.         tempSpeed = settings.slowSpeed
  231.     end
  232.     local tempCFrame = camera.CFrame
  233.     if string.lower(key) == "w" then
  234.         keyW = true
  235.         repeat
  236.             if keyShift == true then
  237.                 tempSpeed = settings.slowSpeed
  238.             else
  239.                 tempSpeed = speed
  240.             end
  241.             camera.CFrame = camera.CFrame + (camera.CFrame.lookVector*tempSpeed)
  242.             focus.CFrame = camera.CFrame + (camera.CFrame.lookVector*1.725)
  243.             RS:wait()
  244.         until keyW == false
  245.     end
  246.     if string.lower(key) == "a" then
  247.         keyA = true
  248.         repeat
  249.             if keyShift == true then
  250.                 tempSpeed = settings.slowSpeed
  251.             else
  252.                 tempSpeed = speed
  253.             end
  254.             tempCFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  255.             camera.CFrame = camera.CFrame + (tempCFrame.lookVector*tempSpeed)
  256.             tempCFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(0), 0)
  257.             focus.CFrame = camera.CFrame + (tempCFrame.lookVector*1.725)
  258.             RS:wait()
  259.         until keyA == false
  260.     end
  261.     if string.lower(key) == "s" then
  262.         keyS = true
  263.         repeat
  264.             if keyShift == true then
  265.                 tempSpeed = settings.slowSpeed
  266.             else
  267.                 tempSpeed = speed
  268.             end
  269.             tempCFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(180), 0)
  270.             camera.CFrame = camera.CFrame + (tempCFrame.lookVector*tempSpeed)
  271.             tempCFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(-180), 0)
  272.             focus.CFrame = camera.CFrame - (tempCFrame.lookVector*1.725)
  273.         RS:wait()
  274.         until keyS == false
  275.     end
  276.     if string.lower(key) == "d" then
  277.         keyD = true
  278.         repeat
  279.             if keyShift == true then
  280.                 tempSpeed = settings.slowSpeed
  281.             else
  282.                 tempSpeed = speed
  283.             end
  284.             tempCFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  285.             camera.CFrame = camera.CFrame + (tempCFrame.lookVector*tempSpeed)
  286.             tempCFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(0), 0)
  287.             focus.CFrame = camera.CFrame + (tempCFrame.lookVector*1.725)
  288.             RS:wait()
  289.         until keyD == false
  290.     end
  291.     if string.lower(key) == "e" then
  292.         keyQ = true
  293.         repeat
  294.             if keyShift == true then
  295.                 tempSpeed = settings.slowSpeed
  296.             else
  297.                 tempSpeed = speed
  298.             end
  299.             tempCFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, 0)
  300.             camera.CFrame = camera.CFrame + (tempCFrame.lookVector*tempSpeed)
  301.             tempCFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(-180), 0, 0)
  302.             focus.CFrame = camera.CFrame - (tempCFrame.lookVector*1.725)
  303.             RS:wait()
  304.         until keyQ == false
  305.     end
  306.     if string.lower(key) == "q" then
  307.         keyE = true
  308.         repeat
  309.             if keyShift == true then
  310.                 tempSpeed = settings.slowSpeed
  311.             else
  312.                 tempSpeed = speed
  313.             end
  314.             tempCFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(-90), 0, 0)
  315.             camera.CFrame = camera.CFrame + (tempCFrame.lookVector*tempSpeed)
  316.             tempCFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0)
  317.             focus.CFrame = camera.CFrame + (tempCFrame.lookVector*1.725)
  318.             RS:wait()
  319.         until keyE == false
  320.     end
  321. end)
  322. mouse.KeyUp:connect(function(key)
  323.     if string.lower(key) == "w" then
  324.         keyW = false
  325.     end
  326.     if string.lower(key) == "a" then
  327.         keyA = false
  328.     end
  329.     if string.lower(key) == "s" then
  330.         keyS = false
  331.     end
  332.     if string.lower(key) == "d" then
  333.         keyD = false
  334.     end
  335.     if string.lower(key) == "e" then
  336.         keyQ = false
  337.     end
  338.     if string.lower(key) == "q" then
  339.         keyE = false
  340.     end
  341.     if keyW == false and keyA == false and keyS == false and keyD == false
  342.         and keyQ == false and keyE == false then
  343.         speed = settings.speed
  344.     end
  345.     if string.byte(key) == 47 or string.byte(key) == 48 then
  346.         keyShift = false
  347.     end
  348. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement