Hi guys, as stated in the title, what parameters were stored inside of "tool.Equipped:connect(function(Entity) end)"? I was trying some really simple stuff like printing the name of the player who've equipped that tool without using localscript. It seems that it returns "nil" here's what I did:
Placed a tool consisting of a script, and a part named "Handle" , inside of starter pack. Here's my code:
tool = script.Parent --Refers to the tool itself handle = tool.Handle --Refers to the part named "Handle" tool.Equipped:connect(function(Entity) local player = Entity.Parent --Parent of the equipped tool should be the player right? print(Entity.Name) --This should display name of player end)
The above code prints out "Instance"
When using something like game.Workspace.Part.Touched:connected(function(Entity) end), it seems to be storing the parameters of whichever entity that triggers this event as a variable of sorts inside "Entity", hence I can do something like:
game.Workspace.Part.Touched:connected(function(**Entity**) print(Entity.Name) --Displays the whatever legs touching the part --And if i want to display the username-- local player = Entity.Parent print(player) end)
Hey lesliesoon,
Tool.Equipped()
has an optional parameter of Mouse. So, Entity is the Mouse of the player that equipped the tool. You can find more information on this here, and also, you know that you can find the parameters of a function by simply searching it up on the wiki. Just search the object itself, and go to the API page on the wiki, and then scroll down to events and find the event that you are looking for, like here.~~ KingLoneCat
Ok thanks, and yes I've already checked that wiki page but the information from the wiki were way too brief, and i didn't quite get it. Take this touched event here as an example. It does tell me that the the parameter used was "otherPart", which is of type base part, but it did not state that any objects touching that part will have its parameters stored inside "otherPart".
I know I'm probably reading something wrong and it would be great if you could correct me on what I should be looking at. I'm usually having trouble with using information from the wiki site.