Advertisement
eruaaaaaaa

Untitled

Aug 1st, 2022
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. handle = script.Parent
  2. tool = handle.Parent
  3. remoteEvent = handle:WaitForChild('RemoteEvent')
  4. player = game.Players.LocalPlayer
  5. UIS = game:GetService('UserInputService')
  6. CAS = game:GetService('ContextActionService')
  7. gui = script:WaitForChild('BallGui'):Clone()
  8. power = 60
  9. powerChange = 5
  10.  
  11. local Ballistic = require(game:GetService("ReplicatedStorage"):WaitForChild("Ballistic"))
  12. Ballistic.Gravity = -handle:WaitForChild("Configuration"):WaitForChild("Gravity").Value
  13.  
  14. if handle:WaitForChild('Configuration'):WaitForChild('RememberPower').Value then
  15. pcall(function()
  16. power = tonumber(script.BallGui.Frame.Disp.Text)
  17. end)
  18. end
  19.  
  20. --handoff input
  21. function ho(str,state,obj)
  22. if state == Enum.UserInputState.Begin then
  23. remoteEvent:FireServer('x down')
  24. else
  25. remoteEvent:FireServer('x up')
  26. end
  27. end
  28.  
  29. --recolor the power wheel and change number
  30. function reDisplay()
  31. for i,v in pairs(gui.Frame:GetChildren()) do
  32. if v.Name~="Disp" then
  33. v.BackgroundTransparency=tonumber(v.Name)<=power and 0 or 0.9
  34. end
  35. end
  36. gui.Frame.Disp.Text=power.."%"
  37. end
  38.  
  39. local mouse = player:GetMouse()
  40. mouse.TargetFilter = workspace
  41.  
  42. local display = Instance.new("Part")
  43. display.BrickColor = BrickColor.new("Really red")
  44. display.Anchored = true
  45. display.CanCollide = false
  46. display.Material = Enum.Material.Neon
  47.  
  48. local function mou()
  49. local mouseLocation = UIS:GetMouseLocation()
  50. local mouseRay = workspace.CurrentCamera:ViewportPointToRay(mouseLocation.X, mouseLocation.Y)
  51. local length = 100
  52.  
  53. local raycast = workspace:Raycast( player.Character:FindFirstChild('Head').Position, mouseRay.Direction.Unit * length)
  54. local position = if raycast then raycast.Position else mouseRay.Origin + (mouseRay.Direction.Unit * length)
  55. return position
  56. end
  57.  
  58. game:GetService("RunService").RenderStepped:Connect(function()
  59. local head = player.Character:FindFirstChild('Head')
  60. if not head then return end
  61.  
  62.  
  63. local origin = workspace.CurrentCamera.CFrame.Position
  64. local traj = Ballistic.SolveMoving(origin, power, workspace.Target.Position, workspace.Target.BodyVelocity.Velocity, not UIS:IsKeyDown(Enum.KeyCode.LeftShift))
  65.  
  66. if traj then
  67. display.Parent = workspace
  68. display.Position = origin + traj
  69. end
  70. end)
  71.  
  72.  
  73.  
  74. tool.Equipped:connect(function(mouse)
  75. mouse.TargetFilter = workspace
  76. mouse.Icon = "rbxasset://textures//GunCursor.png"
  77. mouse.Button1Down:connect(function()
  78. --mouse click
  79. local target = mouse.Hit.p
  80. local head = player.Character:FindFirstChild('Head')
  81. if head then
  82. --thrown event
  83. local origin = head.CFrame.p
  84. gui:Destroy()
  85.  
  86. local dir = origin - workspace.Target.Position
  87.  
  88. --print(Ballistic.GetRange(power, 0))
  89.  
  90.  
  91. remoteEvent:FireServer('Clicked', origin, mouse.Hit.Position, power)
  92. end
  93. end)
  94. gui.Parent = player.PlayerGui
  95. reDisplay()
  96. --mobile button
  97. CAS:BindAction('Handoff', ho, true, Enum.KeyCode.X)
  98. CAS:SetImage('Handoff',"rbxasset://textures//ui//Settings//Help//XButtonDark.png")
  99. end)
  100.  
  101. tool.Unequipped:connect(function(mouse)
  102. gui.Parent = nil
  103. CAS:UnbindAction('Handoff')
  104. end)
  105.  
  106. for i,v in pairs(gui.Frame:GetChildren()) do
  107. if v.Name~="Disp" then
  108. v.MouseButton1Click:connect(function()
  109. power=tonumber(v.Name)
  110. reDisplay()
  111. end)
  112. v.MouseEnter:connect(function()
  113. power=tonumber(v.Name)
  114. reDisplay()
  115. end)
  116. end
  117. end
  118.  
  119. --power change input
  120. UIS.InputBegan:connect(function(input,gpe)
  121. if not gpe then
  122. if input.UserInputType == Enum.UserInputType.Keyboard then
  123. --key down
  124. local key = input.KeyCode
  125.  
  126. if key == Enum.KeyCode.R then
  127. while UIS:IsKeyDown(key) do
  128. power=math.min(100,power+powerChange)
  129. reDisplay()
  130. wait( powerChange/30 );
  131. end
  132. elseif key == Enum.KeyCode.F then
  133. while UIS:IsKeyDown(key) do
  134. power=math.max(0,power-powerChange)
  135. reDisplay()
  136. wait( powerChange/30 );
  137. end
  138. end
  139. end
  140. end
  141. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement