So for this basic example, I am trying to print out the Players ClassName.
script.Parent.Touched:connect(function(player) print(game.Players.player.ClassName) end)
From what I believe this script should print "Player", but instead I get the Error from the Output " player is not a valid member of Players". So how would I go about locating the Player in "Players" through a regular script? Answers appreciated, Thank You.
~ Xduel
script.Parent.Touched:connect(function(player) z = player.Parent:GetPlayerFromCharacter() print(z.ClassName) end)
:GetPlayerFromCharacter()
Helps.
+1 if helped.
script.Parent.Touched:connect(function(hit) --It was hit by a part... possiblename = hit.Parent.Name --So we can find if the hitting part is a player or not. if game.Player:FindFirstChild(possiblename) then --I guess the name is possible. player = game.Player:FindFirstChild(possiblename) --Do what you like to the guy. end end)
The top 2 people were on the right track, but didn't complete theirs.
script.Parent.Touched:connect(function(hit) if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then z =game.Players:GetPlayerFromCharacter(hit.Parent) print(z.ClassName) -- I have a problem with this. Is this a leaderstat? Because it's not a direct child of player. Or is it? end)