Hopefully this should be an easy fix, but I was scrolling the devforum and none of the scenarios quite matched mine.
I have disabled the backpack and want to make it so when you press F, you equip a flashlight tool AND it turns on. I have been able to do so with ManualActivationOnly, but I can still click while the tool is equipped to deactivate it.
Is there a way i could make it so you cannot deactivate the tool by clicking, and instead by pressing F?
it wouldnt turn off if you click if you coded it to only work with key inputs…
just edit the script to use UserInputService instead of MouseClick or whatever the tool click function is
Thanks for the suggestion, I found the solution. I will mark your answer as the solution too bc it helped me solve the issue. For anyone interested, this is my script:
local UserInputService = game:GetService("UserInputService")
local On = false
UserInputService.InputBegan:Connect(function(input, gameprocessed)
if gameprocessed then return end
if input.KeyCode == Enum.KeyCode.F or input.KeyCode == Enum.KeyCode.ButtonL2 then
if On == false then
game.Players.LocalPlayer.Character.Humanoid:EquipTool(script.Parent)
script.Parent:Activate()
script.Parent.Enabled = false
On = true
elseif On == true then
script.Parent.Enabled = true
script.Parent:Deactivate()
game.Players.LocalPlayer.Character.Humanoid:UnequipTools()
On = false
end
end
end)
I may have a few unnecessary lines of code in there but oh well. Thanks for helping!