Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- handle = script.Parent
- tool = handle.Parent
- remoteEvent = handle:WaitForChild('RemoteEvent')
- player = game.Players.LocalPlayer
- UIS = game:GetService('UserInputService')
- CAS = game:GetService('ContextActionService')
- gui = script:WaitForChild('BallGui'):Clone()
- power = 60
- powerChange = 5
- local Ballistic = require(game:GetService("ReplicatedStorage"):WaitForChild("Ballistic"))
- Ballistic.Gravity = -handle:WaitForChild("Configuration"):WaitForChild("Gravity").Value
- if handle:WaitForChild('Configuration'):WaitForChild('RememberPower').Value then
- pcall(function()
- power = tonumber(script.BallGui.Frame.Disp.Text)
- end)
- end
- --handoff input
- function ho(str,state,obj)
- if state == Enum.UserInputState.Begin then
- remoteEvent:FireServer('x down')
- else
- remoteEvent:FireServer('x up')
- end
- end
- --recolor the power wheel and change number
- function reDisplay()
- for i,v in pairs(gui.Frame:GetChildren()) do
- if v.Name~="Disp" then
- v.BackgroundTransparency=tonumber(v.Name)<=power and 0 or 0.9
- end
- end
- gui.Frame.Disp.Text=power.."%"
- end
- local mouse = player:GetMouse()
- mouse.TargetFilter = workspace
- local display = Instance.new("Part")
- display.BrickColor = BrickColor.new("Really red")
- display.Anchored = true
- display.CanCollide = false
- display.Material = Enum.Material.Neon
- local function mou()
- local mouseLocation = UIS:GetMouseLocation()
- local mouseRay = workspace.CurrentCamera:ViewportPointToRay(mouseLocation.X, mouseLocation.Y)
- local length = 100
- local raycast = workspace:Raycast( player.Character:FindFirstChild('Head').Position, mouseRay.Direction.Unit * length)
- local position = if raycast then raycast.Position else mouseRay.Origin + (mouseRay.Direction.Unit * length)
- return position
- end
- game:GetService("RunService").RenderStepped:Connect(function()
- local head = player.Character:FindFirstChild('Head')
- if not head then return end
- local origin = workspace.CurrentCamera.CFrame.Position
- local traj = Ballistic.SolveMoving(origin, power, workspace.Target.Position, workspace.Target.BodyVelocity.Velocity, not UIS:IsKeyDown(Enum.KeyCode.LeftShift))
- if traj then
- display.Parent = workspace
- display.Position = origin + traj
- end
- end)
- tool.Equipped:connect(function(mouse)
- mouse.TargetFilter = workspace
- mouse.Icon = "rbxasset://textures//GunCursor.png"
- mouse.Button1Down:connect(function()
- --mouse click
- local target = mouse.Hit.p
- local head = player.Character:FindFirstChild('Head')
- if head then
- --thrown event
- local origin = head.CFrame.p
- gui:Destroy()
- local dir = origin - workspace.Target.Position
- --print(Ballistic.GetRange(power, 0))
- remoteEvent:FireServer('Clicked', origin, mouse.Hit.Position, power)
- end
- end)
- gui.Parent = player.PlayerGui
- reDisplay()
- --mobile button
- CAS:BindAction('Handoff', ho, true, Enum.KeyCode.X)
- CAS:SetImage('Handoff',"rbxasset://textures//ui//Settings//Help//XButtonDark.png")
- end)
- tool.Unequipped:connect(function(mouse)
- gui.Parent = nil
- CAS:UnbindAction('Handoff')
- end)
- for i,v in pairs(gui.Frame:GetChildren()) do
- if v.Name~="Disp" then
- v.MouseButton1Click:connect(function()
- power=tonumber(v.Name)
- reDisplay()
- end)
- v.MouseEnter:connect(function()
- power=tonumber(v.Name)
- reDisplay()
- end)
- end
- end
- --power change input
- UIS.InputBegan:connect(function(input,gpe)
- if not gpe then
- if input.UserInputType == Enum.UserInputType.Keyboard then
- --key down
- local key = input.KeyCode
- if key == Enum.KeyCode.R then
- while UIS:IsKeyDown(key) do
- power=math.min(100,power+powerChange)
- reDisplay()
- wait( powerChange/30 );
- end
- elseif key == Enum.KeyCode.F then
- while UIS:IsKeyDown(key) do
- power=math.max(0,power-powerChange)
- reDisplay()
- wait( powerChange/30 );
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement