Dropable Tool

If you want mobile players to be more happier in your game

by sparklenico20

Author Avatar

I have seen the comments and I see you guys are confused so I tried to explain it a bit more

Hello guys and to start off make a part

Here we go

img|80x45

(Sorry if it's blurry)

Then insert a tool into the workspace

img|80x45

Name the part Handle and insert a script into the tool type this into the script and the script needs to be a direct child of the tool

local Tool = script.Parent

Tool.Activated:Connect(function() -- This function is run when a player clicks or taps
    Tool.Parent = workspace -- This is where the tool goes
    print("Tool Dropped")
end)

the output should be this

Tool Dropped

If you're wondering what a function is a definition of a command that you can do. We told roblox to activte the function when the player clicks.

And there you have it, a dropable tool on mobile and pc's!

Thanks for reading and I hope this helps you make a better game. This tutorial was just supposed to inspire you to make something.

Context Action Service

Hey guys I am finally adding the button part where when you press a button it drops the tool. If you don't want to type all the code, highlight the code and press ctrl c, even if you are on a mac then press ctrl v or command v on the script. We are now going to make a button to drop the Tool. If you're using a gun then if you click it will not shoot, or it will but will drop. Make a new tool with a local script now, make sure it's a local script or it won't work because Context Action Service can only be put in a local script.

local ContextActionService = game:GetService("ContextActionService")
local Tool = script.Parent
local function DropTool(actionName, inputState, inputObject)
    if inputState == Enum.UserInputState.Begin then
        Tool.Parent = workspace
    end
end
-- The Drop Tool function is what happens when the player presses the button it changes the Parent of the tool to workspace
Tool.Equipped:Connect(function()
    ContextActionService:BindAction("Interact", DropTool, true, Enum.KeyCode.Delete,                      Enum.KeyCode.ButtonR1) -- If player presses R1 on Xbox and Delete on computer
    ContextActionService:SetTitle("Interact", "Drop") -- Set the title to Drop
    ContextActionService:SetPosition("Interact", UDim2.new(1, -70, 0, 10)) -- The Position of the Button
    Tool.Unequipped:Connect(function()
        ContextActionService:UnbindAction("Interact")
    end)
end)

View in-game to comment, award, and more!