script.Parent.Touched:connect(function(Hit) -- I know Hit is what ever hits the script's parent -- But can you explain what Hit is really reffering to like the Player's character end)
GetPlayerFromCharacter() -- idk what this reffers to, like the player's character or am i wrong?
For about one day ago I asked on why my script didn't work.
Someone said that I kept reffering to the Character and yeah i dont remember all.
But can someone explain the difference between .Touched Argument and GetPlayerFromCharacter?
Yes it's a stupid question but I need to know :D!
Ty!
When Touched
fires, it fires with the argument of the single Part
that touched it. This means that it could be for example a part of a tool, the Baseplate, a stray bullet, or even your character's leg.
In the event that it's something from your character, hit.Parent
will be your character itself. That's where Players.GetPlayerFromCharacter
comes in, because it allows you to get the Player
that Character belongs to. In this case, you can do
local PlayerWhoTouched = game.Players:GetPlayerFromCharacter(hit.Parent)
Which tells you primarily:
PlayerWhoTouched
will be nil
if one didn't.From here, you can work with things like their statistics (On the leaderboard), their GUIs, their Backpack and more.