Activated (Event): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Camoy
Added example
m Text replacement - "<SyntaxHighlight code="lua">" to "<syntaxhighlight lang="lua">"
 
(30 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{|
<onlyinclude>{{Event
|<onlyinclude>{{Event|name = Activated
|name = Activated
|arguments =
|description = Fired when the player clicks while a tool is equipped.
|description = Fired when a tool is used.
|objects = [[Tool]], [[StudioTool]]
|object = [[Flag]], [[Tool]]
}}</onlyinclude>
|}}</onlyinclude>
 
|}
{{clear floats}}
{{Example|<pre>
 
{{Example|heading=Example (to be executed while a player is in the game)|
This example prints "Tool activated" when a player clicks while 'tool' is equipped.
<syntaxhighlight lang="lua">
local tool = Instance.new("Tool")
local tool = Instance.new("Tool")
tool.Parent = game.Players.Player.Backpack
tool.Parent = game.Players.Player.Backpack
local function onActivation()
 
function onActivation()
   print("Tool activated")
   print("Tool activated")
end
end
tool.Activated:connect(onActivation)
tool.Activated:connect(onActivation)
</pre>}}
</syntaxhighlight>}}
 
[[Category:Events]]

Latest revision as of 06:17, 27 April 2023

Activated ( )
Description Fired when the player clicks while a tool is equipped.
Member of: Tool, StudioTool


Example (to be executed while a player is in the game)

This example prints "Tool activated" when a player clicks while 'tool' is equipped.

local tool = Instance.new("Tool")
tool.Parent = game.Players.Player.Backpack

function onActivation()
  print("Tool activated")
end

tool.Activated:connect(onActivation)