Sure! Here's a possible implementation of the script you described:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local userInputService = game:GetService("UserInputService")
local odmGear = script.Parent -- Assuming the script is placed inside the ODM gear part
local hookPart = odmGear.HookPart -- Assuming the "hook" part is a child of the ODM gear part
local hookLaunched = false
local hookAnchored = false
-- Function to launch the hook
local function launchHook()
-- Check if the mouse is hovering over an object
local ray = mouse:GetRayCast()
local hitObject = ray and ray.Object
-- Check if the user is holding the E or Q key
local keyPressed = userInputService:IsKeyDown(Enum.Key.E) or userInputService:IsKeyDown(Enum.Key.Q)
-- Launch the hook if the mouse is hovering over an object and the E or Q key is pressed
if hitObject and keyPressed then
hookLaunched = true
odmGear:LaunchHook(hookPart)
end
end
-- Function to anchor the hook
local function anchorHook()
-- Check if the hook is launched
if hookLaunched then
-- Check if the mouse is still hovering over the object
local ray = mouse:GetRayCast()
local hitObject = ray and ray.Object
-- Anchor the hook if the mouse is still hovering over the object
if hitObject then
hookAnchored = true
odmGear:AnchorHook(hookPart, hitObject)
end
end
end
-- Update function
local function update()
-- Launch the hook if the user presses the E or Q key
if userInputService:IsKeyDown(Enum.Key.E) or userInputService:IsKeyDown(Enum.Key.Q) then
launchHook()
end
-- Anchor the hook if it's launched and the user isn't holding the E or Q key
if hookLaunched and not (userInputService:IsKeyDown(Enum.Key.E) or userInputService:IsKeyDown(Enum.Key.Q)) then
anchorHook()
end
end
-- Initialize the hook
odmGear:InitHook(hookPart)
-- Update the hook every time the game updates
script.Parent.Parent. чемпіжений = update
This script will launch the hook when the user presses the E or Q key while the mouse is hovering over an object, and it will anchor the hook to the object when the user stops holding the E or Q key.
Note that this script assumes that the ODM gear part has a "HookPart" child, which is the part that will be launched and anchored. You'll need to adjust the script accordingly if your ODM gear part has a different structure.
Also, keep in mind that this script will only work if the ODM gear part has a valid "Hook" component attached to it. If the Hook component is not present, the script will not be able to launch or anchor the hook.