Advertisement
OnFireRobloxScriptin

Press Key to Drop Tool Script

Jul 23rd, 2024
1,372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. --//Services
  2. local Players = game:GetService("Players") --Gets the Player Service
  3. local UserInputService = game:GetService("UserInputService") --Gets the UserInputService
  4.  
  5. --//Variables
  6. local player = Players.LocalPlayer --Gets the player
  7. local character = player.Character or player.CharacterAdded:Wait() --Gets the Player's character
  8.  
  9. --//Function
  10. local function dropTool() --Creates a new function called "dropTool"
  11.     local tool = character:FindFirstChildOfClass("Tool") --Checks for the tool the player is holding
  12.     if tool then --If the tool exsits
  13.         tool.Parent = workspace --Places tool in the workspace (your game)
  14.         tool.Handle.Position = character.HumanoidRootPart.Position --Places it at the HumanoidRootPart
  15.     end
  16. end
  17.  
  18. --//Drop tool
  19. UserInputService.InputBegan:Connect(function(input, gameProcessed) --When the player presses any key on their keyboard
  20.     if input.KeyCode == Enum.KeyCode.Q and not gameProcessed then --Checks if the letter is "Q" and if the game has NOT processed it, change Q to whatever key you want
  21.         dropTool() --Call the dropTool function
  22.     end
  23. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement