How do you make a tool that cannot be activated through clicking, but can be activated using Tool:Activate()? I know it’s possible to achieve vice-versa using Tool.ManualActivation, But I want to make it so you can ONLY activate a tool through Tool:Activate().
My plan is to use a button from ContextActionService to fire the tool’s activation.
You can’t really do that. You should instead use events or something of the sort to “simulate” the activation instead. Unfortunately, Roblox doesn’t have an option for something like that so you’ll have to work around it.
-- localscript inside tool
local contextActionService = game:GetService("ContextActionService")
local tool = script.Parent
local function ActionFunction(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
print("Tool has been activated")
else
print("Tool has been deactivated")
end
end
tool.Equipped:Connect(function()
contextActionService:BindAction("ActionId", ActionFunction, true, Enum.KeyCode.H, Enum.KeyCode.ButtonY)
end)
tool.Unequipped:Connect(function()
contextActionService:UnbindAction("ActionId")
end)