Tool.Equipped Not Working For Me

Right now I’m trying to make a tool that uses Equipped to tell when, you know, It’s equipped. But, for some reason it just wouldn’t run.

I’ve tried formatting the function in three different ways:

The script is a server script placed directly inside the tool.

local tool = script.Parent

local function onEquipped()
    -- my code
end

tool.Equipped:Connect(onEquipped)
local tool = script.Parent

function onEquipped()
    -- my code
end

tool.Equipped:Connect(onEquipped)
local tool = script.Parent

tool.Equipped:Connect(function()
    -- my code
end)

Help plz

3 Likes

equipped only works in a local script I think

3 Likes

Have you tried putting print statements inside of the function? That’s my most useful debugging tool.

2 Likes

@Sniperkaos is correct, it needs to be inside a local script since the tool is client-sided and localised. Any code inside the function should be aimed for client-sided use also, so make sure your code inside the function is working. As @ElusiveEpix said, you should put some print statements inside the function to test if the function itself works before working on the code inside the function. Good luck!

2 Likes

It’s because there needs to be a handle in the tool. I found it out earlier but didn’t share it because I didn’t want to bump a useless topic.

But yeah I should’ve just edited the topic.

12 Likes

theres another way i was having the same problem and saw your post that it requires the handle, But if you set HandleRequired property to false it works

4 Likes

Now it doesn’t work on a client. Zoinks!

edit:
I can just do this for now:

function AncestryChanged()
    if not game.Players:GetPlayerFromCharacter(Tool.Parent)then
        return
    end
    -- my code here
end

Tool.AncestryChanged:Connect(AncestryChanged)
3 Likes