Advertisement
HouseV3rm

Flashlight

Jul 12th, 2020
4,943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.79 KB | None | 0 0
  1. Players = game:GetService("Players")
  2. LocalPlayer = Players.LocalPlayer
  3. Backpack = LocalPlayer.Backpack
  4. StarterGui = game:GetService("StarterGui")
  5.  
  6. local Flashlight = Instance.new("Tool", Backpack)
  7. Flashlight.GripPos = Vector3.new(0.1, -0.4, 0)
  8. Flashlight.Name = "Flashlight"
  9. Flashlight.TextureId = "http://www.roblox.com/asset/?id=115955232"
  10.  
  11. local Handle = Instance.new("Part", Flashlight)
  12. Handle.BrickColor = BrickColor.new("Bright yellow")
  13. Handle.Color = Color3.fromRGB(245, 205, 48)
  14. Handle.Name = "Handle"
  15. Handle.Locked = true
  16. Handle.Size = Vector3.new(0.5, 0.5, 2)
  17. Handle.CanCollide = true
  18.  
  19. local LightPart = Instance.new("Part", Flashlight)
  20. LightPart.BrickColor = BrickColor.new("Mid gray")
  21. LightPart.Color = Color3.fromRGB(205, 205, 205)
  22. LightPart.Transparency = 1
  23. LightPart.Name = "LightPart"
  24. LightPart.CanCollide = false
  25. LightPart.Locked = true
  26. LightPart.Size = Vector3.new(0.2, 0.2, 0.2)
  27.  
  28. local Motor = Instance.new("Motor", Flashlight)
  29. Motor.Part0 = Handle
  30. Motor.Part1 = LightPart
  31.  
  32. local Sound = Instance.new("Sound", Handle)
  33. Sound.SoundId = "http://www.roblox.com/asset/?id=115959318"
  34. Sound.Volume = 1
  35.  
  36. local Mesh = Instance.new("SpecialMesh", Handle)
  37. Mesh.Name = "Mesh"
  38. Mesh.MeshId = "http://www.roblox.com/asset/?id=115955313"
  39. Mesh.MeshType = "FileMesh"
  40. Mesh.Scale = Vector3.new(0.7, 0.7, 0.7)
  41. Mesh.TextureId = "http://www.roblox.com/asset?id=115955343"
  42.  
  43. local SpotLight = Instance.new("SpotLight", LightPart)
  44. SpotLight.Name = "SpotLight"
  45. SpotLight.Angle = 70
  46. SpotLight.Color = Color3.fromRGB(244, 255, 233)
  47. SpotLight.Enabled = false
  48. SpotLight.Face = "Front"
  49. SpotLight.Range = 32
  50.  
  51. local SpotLight2 = Instance.new("SpotLight", LightPart)
  52. SpotLight2.Name = "SpotLight2"
  53. SpotLight2.Angle = 70
  54. SpotLight2.Brightness = .75
  55. SpotLight2.Color = Color3.fromRGB(244, 255, 233)
  56. SpotLight2.Enabled = false
  57. SpotLight2.Range = 60
  58.  
  59. sp = Flashlight
  60.  
  61. cooldown = .35
  62.  
  63. lightontexture = 115984370
  64. lightofftexture = 115955343
  65.  
  66. local weld = sp:WaitForChild("Motor")
  67. local lp = sp:WaitForChild("LightPart")
  68. local handle = sp:WaitForChild("Handle")
  69. local spotlight = lp:WaitForChild("SpotLight")
  70. local spotlight2 = lp:WaitForChild("SpotLight2")
  71. local mesh = handle:WaitForChild("Mesh")
  72. local sound = handle:WaitForChild("Sound")
  73. lastclick = 0
  74.  
  75. sp.Equipped:connect(
  76.     function(mouse)
  77.         equipped = true
  78.         if mouse ~= nil then
  79.             themouse = mouse
  80.             mouse.Button1Down:connect(
  81.                 function()
  82.                     if lastclick + cooldown < tick() then
  83.                         spotlight.Enabled = not spotlight.Enabled
  84.                         spotlight2.Enabled = spotlight.Enabled
  85.                         mesh.TextureId =
  86.                             "http://www.roblox.com/asset?id=" ..
  87.                             tostring((spotlight.Enabled and lightontexture) or lightofftexture)
  88.                         sound:Play()
  89.                         lastclick = tick()
  90.                     end
  91.                 end
  92.             )
  93.         end
  94.         if weld ~= nil then
  95.             weld.Parent = sp
  96.         end
  97.         while equipped and sp.Parent ~= nil do
  98.             local head = sp.Parent:FindFirstChild("Head")
  99.             if spotlight.Enabled and themouse and handle and weld and head then
  100.                 local vec = themouse.Hit.p - head.Position
  101.                 local pos = (handle.CFrame * CFrame.new(0, 0, -1)).p
  102.                 local cf = CFrame.new(pos, pos + vec)
  103.                 --lp.CFrame=cf
  104.                 weld.C0 = handle.CFrame:toObjectSpace(cf)
  105.             end
  106.             wait()
  107.         end
  108.     end
  109. )
  110.  
  111. sp.Unequipped:connect(
  112.     function()
  113.         if weld ~= nil then
  114.             weld.Parent = sp
  115.         end
  116.         equipped = false
  117.     end
  118. )
  119.  
  120.  
  121. local Flashlight2 = Flashlight:clone()
  122. Flashlight2.Parent = StarterGui
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement