Advertisement
Caigepayne

Untitled

Jun 7th, 2019
8,902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. this is my script so far
  2.  
  3. -------------CREATES THE POINT I WANNA AIM AT-----------------
  4. Instance.new("Part",game.Workspace)
  5. game.Workspace.Part.Name="Green"
  6. game.Workspace.Green.CFrame=CFrame.new(35.7394753, 3, -23.1335964, -0.0204065256, 0, -0.999793291, 0, 1, 0, 0.999793291, 0, -0.0204065256)
  7. game.Workspace.Green.Anchored=true
  8. game.Workspace.Green.Size=Vector3.new(1,1,1)
  9. game.Workspace.Green.BrickColor=BrickColor.Green()
  10. ---------------------------------------------------------------------
  11. -------------------------------Creates a wall--------------------------
  12. Instance.new("Part",game.Workspace)
  13. game.Workspace.Part.Name="Wall"
  14. game.Workspace.Wall.CFrame=CFrame.new(-7.33410549, 3, -24.0379162, -0.0346626081, -3.2247442e-08, -0.99939847, -6.16503897e-08, 0.99999994, -3.0128664e-08, 0.99939847, 6.05688868e-08, -0.0346626081)
  15. game.Workspace.Wall.Anchored=true
  16. game.Workspace.Wall.Size=Vector3.new(30,30,1)
  17. game.Workspace.Wall.Transparency=0.5
  18. ---------------------------------------------------------------------
  19.  
  20. wait()
  21.  
  22. ------------------------Toggles the aim------------------------------
  23. local UserInputService = game:GetService("UserInputService");
  24.  
  25. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  26. if input.KeyCode == Enum.KeyCode.Q then
  27. if game.Workspace:FindFirstChild("Green") then
  28. game.Workspace.Green.Name="Green2"
  29. else
  30. game.Workspace.Green2.Name="Green"
  31. end
  32. end
  33. end)
  34. ---------------------------------------------------------------------
  35.  
  36. -- THE GUD PART--
  37. while true do
  38. wait()
  39. if game.Workspace:FindFirstChild("Green") then
  40. local point1 = game.workspace.ZetaIsBack.Head
  41. local point2 = game.workspace.Green
  42.  
  43. local camera = workspace.CurrentCamera
  44. local worldPoint = Vector3.new(point2.Position)
  45. local vector, inViewport = camera:WorldToViewportPoint(worldPoint)
  46.  
  47. local distance = math.floor((point1.Position - point2.Position).Magnitude)
  48. print(distance)
  49. local ray = Ray.new(point1.CFrame.Position, (point2.CFrame.Position - point1.CFrame.Position) )
  50. local part,position = game.workspace:FindPartOnRay(ray,point2,false,true)
  51.  
  52. if not part then -- if the ray is colliding with any part then
  53. if inViewport == true then
  54. if distance<100 then
  55. game.Workspace.CurrentCamera.CFrame=CFrame.new(game.workspace.CurrentCamera.CFrame.Position,game.workspace.Green.CFrame.Position)
  56. end
  57. end
  58. end
  59. end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement