Tool.Activated not working correctly?

I looked at some other posts on the devforum considering this problem and none of them were the solution.

game.Workspace.room2.Tools.BlueKey2.Activated:Connect(function()
	print("blue key activated")
end)

here is a picture of the hierarchy if you can find a problem with it
Screen Shot 2021-01-03 at 3.28.45 PM

When I equip it nothing happens, no print statement :confused:

1 Like

How are you equipping the tool if it is in a folder in the workspace? You can only equip tools that are in your backpack, unless you are equipping it manually through a script. You may also want to add WaitForChild statements to ensure that everything has loaded in.

I am equipping it manually through a script when I click on it

Do you clone the tool or do you equip that exact tool?

I equip the exact tool. I set the parent to the local players backpack.

And there are no errors? Maybe try this to see if it registers it being equipped. I doubt this would be the problem but maybe if you are moving the tool to the players backpack with a local script then the server doesn’t realize that it is there, so it never registers the tool.Activated:

local tool = game.Workspace:WaitForChild("room2"):WaitForChild("Tools"):WaitForChild("BlueKey2")

tool.Equipped:Connect(function()
      print("Equipped")
end)

tool.Activated:Connect(function()
       print("Activated")
end)

while wait(2) do
       print(tool.Parent) --to see if it registers when the player has it in their backpack or in their character
end

You’re getting the tool from Workspace, which isn’t good practice as the tool could be located anywhere. The player can’t activate the tool in Workspace. Where is your script located?

If it is inside the tool, you should instead do

script.Parent.Activated:Connect(function()
	print("blue key activated")
end)

Connect the .Activated event after you put the tool in the player’s backpack/character. Also if your tool doesn’t have a handle make sure the .RequiresHandle property of the tool is disabled

it is a local script in the starterGUI this is an escape room game where the player finds the key and click on it so it is teleported to the players backpack.

If I am understanding you correctly, you want players to click the tool and it will appear in their backpack? If this is your intention, I would use ClickDetector.MouseClick

local LocalPlayer = game:GetService("Players").LocalPlayer
local Tool = workspace.room2.Tools.BlueKey2

Tool:GetPropertyChangedSignal("Parent"):Connect(function()
	if Tool.Parent == LocalPlayer.Backpack then -- check if the tool gets put in the player's backpack
		Tool.Activated:Connect(function() -- if the tool is put in backpack, then connect the .Activated signal
			print("blue key activated")
		end)
	end
end)

I use a click detector and it works I do not need help for this but thanks anyway :upside_down_face:

I tried it, it still doesn’t print anything and no errors, do you think that it could be a problem with studio?

I haven’t even tried this yet instead of doing .Activated I used .Equipped thanks for the help everyone :sweat_smile: