Advertisement
KrnlBypasser

Application

Jun 25th, 2025 (edited)
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.28 KB | Source Code | 0 0
  1. -- hai :3
  2.  
  3. --// Services
  4. local UserInputService = game:GetService("UserInputService")
  5. local ContextActionService = game:GetService("ContextActionService")
  6. local RunService = game:GetService("RunService")
  7. local Players = game:GetService("Players")
  8.  
  9. --// Player and Character
  10. local player = Players.LocalPlayer
  11. local character = player.Character or player.CharacterAdded:Wait()
  12. local humanoid = character:WaitForChild("Humanoid")
  13. local rootPart = character:WaitForChild("HumanoidRootPart")
  14.  
  15. --// Configuration
  16. local SWING_FORCE = 50
  17. local JUMP_BOOST = 50
  18.  
  19. --// State Management
  20. local GrapplingHook = {}
  21. GrapplingHook.__index = GrapplingHook
  22.  
  23. function GrapplingHook.new()
  24.     local self = setmetatable({}, GrapplingHook)
  25.     self.state = "Idle"
  26.     self.hookPart = nil
  27.     self.beam = nil
  28.     self.attachment0 = nil
  29.     self.attachment1 = nil
  30.     self.alignPosition = nil
  31.     self.alignOrientation = nil
  32.     return self
  33. end
  34.  
  35. function GrapplingHook:setState(newState)
  36.     if self.state == newState then return end
  37.     print("Grappling Hook State:", newState)
  38.     self.state = newState
  39. end
  40.  
  41. --// Grappling Hook Instance
  42. local hook = GrapplingHook.new()
  43.  
  44. --// Creating hook visual :P
  45. function createHookPart()
  46.     local part = Instance.new("Part")
  47.     part.Size = Vector3.new(1, 1, 1)
  48.     part.BrickColor = BrickColor.new("Gray")
  49.     part.Material = Enum.Material.Metal
  50.     part.Anchored = true
  51.     part.CanCollide = false
  52.     part.Name = "HookPart"
  53.     part.Parent = workspace
  54.     return part
  55. end
  56.  
  57. --// Fire the grappling hook
  58. function fireHook()
  59.     if hook.state ~= "Idle" then return end
  60.  
  61.     local mouse = player:GetMouse()
  62.     local targetPosition = mouse.Hit.p
  63.     local originPosition = rootPart.Position
  64.  
  65.     local direction = (targetPosition - originPosition).Unit * 10000
  66.  
  67.     local raycastParams = RaycastParams.new()
  68.     raycastParams.FilterDescendantsInstances = {character}
  69.     raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
  70.     local raycastResult = workspace:Raycast(originPosition, direction, raycastParams)
  71.  
  72.     if not raycastResult or not raycastResult.Instance then
  73.         return
  74.     end
  75.  
  76.     hook:setState("Attached")
  77.     hook.hookPart = createHookPart()
  78.     hook.hookPart.Position = raycastResult.Position
  79.  
  80.     -- Create attachments
  81.     hook.attachment0 = Instance.new("Attachment", rootPart)
  82.     hook.attachment1 = Instance.new("Attachment", hook.hookPart)
  83.  
  84.  
  85.     -- Create the beam but start it as disabled
  86.     hook.beam = Instance.new("Beam")
  87.     hook.beam.Enabled = false
  88.  
  89.     -- Assign attachments and visual properties
  90.     hook.beam.Attachment0 = hook.attachment0
  91.     hook.beam.Attachment1 = hook.attachment1
  92.     hook.beam.Color = ColorSequence.new(Color3.new(0.8, 0.8, 0.8))
  93.     hook.beam.FaceCamera = true
  94.     hook.beam.Width0 = 0.1
  95.     hook.beam.Width1 = 0.1
  96.  
  97.  
  98.     hook.beam.Parent = hook.hookPart
  99.  
  100.  
  101.     hook.beam.Enabled = true
  102.  
  103.  
  104.     attachPlayer()
  105. end
  106.  
  107. --// Attach the player and start swinging around :D
  108. function attachPlayer()
  109.     if hook.state ~= "Attached" then return end
  110.  
  111.     hook:setState("Swinging")
  112.     humanoid.Sit = true -- must be a rock to simple not jump on the platform
  113.  
  114.     -- Physics constraints for swinging
  115.     hook.alignPosition = Instance.new("AlignPosition")
  116.     hook.alignPosition.Attachment0 = hook.attachment0
  117.     hook.alignPosition.Attachment1 = hook.attachment1
  118.     hook.alignPosition.Responsiveness = 20
  119.     hook.alignPosition.Parent = rootPart
  120.  
  121.     hook.alignOrientation = Instance.new("AlignOrientation")
  122.     hook.alignOrientation.Attachment0 = hook.attachment0
  123.     hook.alignOrientation.Attachment1 = hook.attachment1
  124.     hook.alignOrientation.Responsiveness = 10
  125.     hook.alignOrientation.Parent = rootPart
  126. end
  127.  
  128. --// Handle player input for swinging
  129. function onUpdate(dt)
  130.     if hook.state ~= "Swinging" then return end
  131.  
  132.     local moveDirection = humanoid.MoveDirection
  133.     if moveDirection.Magnitude > 0 then
  134.         local force = rootPart.CFrame:VectorToWorldSpace(moveDirection) * SWING_FORCE
  135.         rootPart:ApplyImpulse(force)
  136.     end
  137. end
  138.  
  139. --// Release the grappling hook
  140. function releaseHook()
  141.     if hook.state == "Idle" then return end
  142.  
  143.     if hook.state == "Swinging" then
  144.         local jumpForce = rootPart.CFrame.UpVector * JUMP_BOOST
  145.         rootPart.Velocity = rootPart.Velocity + jumpForce
  146.     end
  147.  
  148.     cleanup()
  149. end
  150.  
  151. --// Cleanup resources
  152. function cleanup()
  153.     hook:setState("Idle")
  154.     if hook.hookPart then
  155.         hook.hookPart:Destroy()
  156.         hook.hookPart = nil
  157.     end
  158.     if hook.beam then
  159.         hook.beam:Destroy()
  160.         hook.beam = nil
  161.     end
  162.     if hook.attachment0 then
  163.         hook.attachment0:Destroy()
  164.         hook.attachment0 = nil
  165.     end
  166.     -- No need to handle attachment1, it gets destroyed with hookPart
  167.     hook.attachment1 = nil
  168.     if hook.alignPosition then
  169.         hook.alignPosition:Destroy()
  170.         hook.alignPosition = nil
  171.     end
  172.     if hook.alignOrientation then
  173.         hook.alignOrientation:Destroy()
  174.         hook.alignOrientation = nil
  175.     end
  176.     humanoid.Sit = false
  177. end
  178.  
  179. --// Input Handling -- THIS FUNCTION ALLOWS THE USER TO JUMP WHEN WALKING AROUND
  180. function onAction(actionName, inputState, inputObject)
  181.     if actionName == "Grapple" and inputState == Enum.UserInputState.Begin then
  182.         fireHook()
  183.         return Enum.ContextActionResult.Sink -- Prevents mouse click from doing other things
  184.     end
  185.  
  186.     if actionName == "Release" and inputState == Enum.UserInputState.Begin then
  187.         -- Only release the hook if it's currently active
  188.         if hook.state ~= "Idle" then
  189.             releaseHook()
  190.             -- Sink the input so we don't also do a normal jump
  191.             return Enum.ContextActionResult.Sink
  192.         else
  193.             -- If the hook is idle, pass the input so the default jump can happen
  194.             return Enum.ContextActionResult.Pass
  195.         end
  196.     end
  197.  
  198.     -- For any other input, let the game handle it normally
  199.     return Enum.ContextActionResult.Pass
  200. end
  201.  
  202. --// Bind actions and update loop
  203. ContextActionService:BindAction("Grapple", onAction, true, Enum.UserInputType.MouseButton1)
  204. ContextActionService:BindAction("Release", onAction, true, Enum.KeyCode.Space)
  205. RunService.Heartbeat:Connect(onUpdate)
  206.  
  207. print("Grappling Hook system initialized.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement