Tool.Activated not working?

Tool.Activated isn’t working whatsoever for me, I have the new Lua VM enabled if that could cause it.

script.Parent.Activated:Connect(function()
print’a’
end)

Update: apparently roblox isn’t registering the tool as being equipped? And it’s not happening to other people? I’ve tried restarting studio and the same thing happens in game as well.

2 Likes
script.Parent.Activated:Connect(function()
	print('a') -- there is the mistake 
end)

I tried this code in a script and a local script with the new Lua VM and it worked fine.

2 Likes

how is that a mistake? You don’t need parenthesis for the print to work…

3 Likes

Screenshot_1
Screenshot_2

Maybe, you are using wrong quotes?

1 Like

image

today i learned.

anyways, this code of mine is working for activated:
Tool.Activated:connect(Activated)

I guess it’s just a bug for me then, I updated the post and apparently roblox isn’t detecting the tool as being equipped…

1 Like

lua functions do not need parenthesis if the parameter is a string or a table

do you have checks in your script to make sure the line is not running before being equipped?

look at the image I sent, I manually run Tool:Activate() while the tool is under my character, but it doesnt work because roblox thinks it’s not equipped.

you can simply run it in an equipped event

Also, if the tool doesnt have a handle and Tool.RequiresHandle is true, then the activated event wont fire

11 Likes

Wow I didn’t even realize I had requireshandle on, I’m an idiot. Thank you

2 Likes

This is wildly off-topic, but I figure it’s worth addressing: this is a valid way to write quotes. If the quotes were incorrect, it’d throw an error - your quotes threw an error because they’re different symbols altogether. Despite them being quotes, they sport an unaccepted unicode character.

There are four or so valid ways to write quotes in Lua:

print("Hello world") -- Most common
print('Hello world')
print([[Hello world]]) -- Helpful for multi-line quotes
print([==[Hello world]==]) -- Don't ask why this is valid. Similar to above.

Print is a function that accepts variable arguments (represented as …), which means you can pass any number of arguments to it. All arguments passed to print have tostring called on them. For userdata, the __tostring metamethod is invoked by nature of using tostring.

As far as functions accepting arguments goes: if you are only passing a single argument to a function, Lua allows you to bypass parenthesis for values of type string or table.

print "Hello world"
print {A = "B"} -- Will print the table's memory address though

And finally, a comment on your post: please make sure you read and understand the thread first before offering up a response. OP’s issue is very clearly outlined in the topic thread and so is the error that’s occurring. Using different quotes would have no affect on the behaviour of Tool.Activated: it’s that the Tool isn’t registered as equipped because a certain condition wasn’t fulfilled.

6 Likes