Tool.Activated Firing Incorrectly


Repro.rbxl (252.5 KB)
(Press E to call Tool:Activate(), using LocalScript)

To briefly explain;

Tool

Non of them behave they way described in the DevHub;

  • Activated fires when Enabled is false
  • Activated fires when RequiresHandle is true but has no Handle
  • Activated fires when Activate is called and MouseClick when ManualActivationOnly is true

This happens for both Server and Client.

I haven’t tested this with ContextActionService


Code

Server-Side

local Tool = script.Parent

Tool.Activated:Connect(function()
	print("Server Activated")
	print("Server Enabled",Tool.Enabled)
	print("Server ManualActivationOnly",Tool.ManualActivationOnly)
	print("___")
end)

Client-Side

local PlayerS = game:GetService('Players')
	local plr = PlayerS.LocalPlayer

local ContextActionS = game:GetService('ContextActionService')

local Tool = script.Parent

Tool.Activated:Connect(function()
	print("Client Activated")
	print("Client Enabled",Tool.Enabled)
	print("Client ManualActivationOnly",Tool.ManualActivationOnly)
end)

ContextActionS:BindAction("SetStateEnabled",function(_,State)
	if State == Enum.UserInputState.Begin then
		Tool:Activate()
	end
end,false,Enum.KeyCode.E)
2 Likes

Hi–I just ran your Repro.rbxl and when I clicked on your ManualActivationOnly
(and it turned green) then clicking in world did NOT activate your text output, so the lockout
feature seems to work as intended (I clicked the button again and it turned green
and then the text output resumed again on clicks in world.) I didn’t look at the code because
things seemed to be working properly and didn’t seem to show some of what you observed.
Studio just updated before I ran it–Possibly they already fixed something?

1 Like

Thank you for your observation; ManualActivationOnly is working fine, I was confused by it’s name and description, however Activated still fires when Enabled is false upon calling Activate

Yeah, I’m not surprised by either; “Manual” could suggest something with the hands eg. a mouse, but
yes it means the opposite. It doesn’t surprise me at all regarding the documentation. Have you checked
to see if it makes a difference if you set/clear the Enabled Property in Server-side Scripts instead of LocalScripts? (Your demo shows that the client-side Enabled changes are not replicated to the server.)
This may be a security feature of sorts, as there are lots of things that have changed to only work to
change state if done server-side.

No it doesn’t make any differences, I’ve tested by manually setting the properties before entering the game and during the session.

It also doesn’t make sense that setting the Tools properties on the Client would fire Activated regardless.

The demo is to simply show that no matter what you do Activated will always fire.

Yeah, that doesn’t surprise me either–I’ve always treated it as a convenience flag. And Tools typically
create the effect you’re expecting by simply returning at the beginning of the Activated handler if Enabled
is false. I actually prefer it this way (counter to the documentation) as it gives more flexibility in how a
Tool can work. eg. more user feedback during weapon reload.

Hey everyone, I’m bumping this thread because this issue has either re-surfaced or it was never fixed in the first place. I’m attaching both a video and a repro where Tool.Activated and Tool.Deactivated both fire when Enabled=False and ManualActivationOnly=False, and Tool.Deactivated fires when Enabled=False and ManualActivationOnly=True. I also included a gui button with a localscript that calls Tool::Activate (and then ::Deactivate) for the MAO Tool when parented to the local character, which still fires the corresponding events for the tool

ToolEnabledFalse.rbxl (34.4 KB)

3 Likes