Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is Tool.Equipped function not working?

This is probably going to sound like a stupid question but I don't understand. So all I'm trying to do is when you have a tool out (mine is named "Testing Tablet" then a Gui appears but the problem is when I just do this:

Tool.Equipped:Connect(function(mouse)
	print("Hello world")
end)

That script still is not working. I've had some ideas but when I changed some things in the properties it still wouldn't work.

  • I did
local StarterPack = game:GetService("StarterPack")
local Tool = game.StarterPack["Testing Tablet"]

before I did the Equipped function.

  • One part in the Tool is named Handle

I was wondering if anyone knew what I was doing wrong. Thanks!

2 comments

0

Is it a localScript? It should be.

0

Yes it's in a localScript.

2 answers

✓ Accepted answer

You're trying to access the tool which is in StarterPack You should be trying to access the tool which is in the player's backpack.

So, to do this... Place a LocalScript inside the tool and paste the following:

local Tool = script.Parent
Tool.Equipped:Connect(function(mouse)
    print("Hello world")
end)

And that should work... However if you, for some reason, want to control all tools from one script... You can put the LocalScript in StarterCharacterScripts and paste the following

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local backpack = player:WaitForChild("Backpack") -- :WaitForChild() as the backpack may take a while to load

local Tool = backpack:WaitForChild("Testing Tablet") -- same reason here
Tool.Equipped:Connect(function(mouse)
    print("Hello world")
end)

Hope this helps. If it does, don't forget to accept my answer :) Also here is the article on Tool.Equipped.

Kind regards, rodrigo455

So basically the way tools work is once a player spawns they are replicated into the players character. Simply define the tool as a child of the character.

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local tool = char:WaitForChild("DesiredTool") -- change desired tool to your tool's name

2 comments

0

It worked! Thank you!

0

(Forgot to clarify that it is when the tool is equipped)

This discussion is preserved as it was. New answers, comments, and votes are closed.