When someone clicks a click detector does the click detector react to the player in "Players" or in the players model in workspace?
Like when you're doing ontouched and you put
function onTouched(hit)
the 'hit' is the player model but when I do the same with OnClicked does the hit mean the player in 'Players' or the players model?
The "player model" you're referring to is more fittingly called the Character
. The Touched
event's only parameter is the part that touched. This means that, if a player's character touches it, the character model will be part.Parent
. These are examples with :GetFullName()
, which returns a string displaying the object's ancestory.
local part = workspace.Part part.Touched:Connect(function(otherPart) print(otherPart:GetFullName()) --will print something like "game.workspace.gioni01.Torso" end)
The MouseClick
event of ClickDetector
s has one parameter: the player who clicked (the object in the Players
service, as you said).
local part = workspace.Part local ClickDetector = part.ClickDetector ClickDetector.MouseClick:Connect(function(player) print(player:GetFullName()) --> prints "game.Players.gioni01" end)
Don't be discouraged when you're not sure of the parameters of an event. Short of guessing, you simply cannot know until you search them on the wiki!
hit is not the player's model. In Touched events, that is the parameter passed to your event listener, which is the other part that touches the part. It doesn't have to be named hit; it is merely convention to name it like that, as it is the part that hit your brick. If a player touches a part, it is a body part from their character, for example the left foot. It does not have to be the player either. Anything can touch other parts.
This is not a very meaningful question, as it depends on what the event listener of the ClickDetector event does.