Advertisement
crunchbone

Untitled

Apr 22nd, 2021
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. --CFrame.new(workspace.Camera.CFrame.Position+(workspace.Camera.CFrame.LookVector*10)) //VOID// use raycast
  2. local Toolbar = plugin:CreateToolbar("Building pack use")
  3.  
  4. local PackSetButton = Toolbar:CreateButton("Set pack","Sets pack to use","rbxthumb://type=Avatar&id=1459338293&w=720&h=720")
  5. local PackToggleButton = Toolbar:CreateButton("Toggle pack","toggle 1 - 0 keys ","rbxthumb://type=Avatar&id=81951343&w=720&h=720")
  6. local PackClearButton = Toolbar:CreateButton("Clear pack","remove pack","rbxthumb://type=Avatar&id=1&w=720&h=720")
  7.  
  8. local pack = {}
  9. local Selection = game:GetService("Selection")
  10. local connections = {}
  11. local numsAsWords = {
  12. [1] = Enum.KeyCode.One,
  13. [2] = Enum.KeyCode.Two,
  14. [3] = Enum.KeyCode.Three,
  15. [4] = Enum.KeyCode.Four,
  16. [5] = Enum.KeyCode.Five,
  17. [6] = Enum.KeyCode.Six,
  18. [7] = Enum.KeyCode.Seven,
  19. [8] = Enum.KeyCode.Eight,
  20. [9] = Enum.KeyCode.Nine,
  21. [0] = Enum.KeyCode.Zero,
  22. }
  23.  
  24. local params = RaycastParams.new()
  25.  
  26.  
  27. function raycast(origin, direction)
  28. local result = game:GetService("StudioService"):GizmoRaycast(origin,(direction).unit*999)
  29. if result then
  30. return result.Position
  31. else
  32. print("NOT HIT")
  33. end
  34. end
  35.  
  36. function getPlacePos(camera)
  37. local posz = raycast(camera.CFrame.Position,(camera.CFrame.Position-camera.CFrame.LookVector))
  38. return posz
  39. end
  40.  
  41. function clearKeybinds()
  42. for i,v in pairs(connections) do
  43. v:disconnect()
  44. end
  45. end
  46.  
  47. PackSetButton.Click:Connect(function()
  48. clearKeybinds()
  49. local selected = Selection:Get()
  50. for i=1,10 do
  51. pack[i] = selected[i]
  52. end
  53. end)
  54.  
  55. PackClearButton.Click:Connect(function()
  56. pack = {}
  57. clearKeybinds()
  58. end)
  59.  
  60. PackToggleButton.Click:Connect(function()
  61. for i=1,10 do
  62. connections[i] = game:GetService("UserInputService").InputBegan:Connect(function(k, r)
  63. if k.KeyCode == numsAsWords[i] then
  64. local obj = pack[i]:Clone()
  65. local position = getPlacePos(workspace.Camera)
  66. obj.Position = position
  67. obj.Parent = workspace
  68. end
  69. end)
  70. end
  71. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement