I am making a script in which it needs to find the players and the character and interacts with both. I know how to find all the players in the game as you can see but I don't know how to find all the characters(where the torso and stuff is)
01 | game.Players.PlayerAdded:connect( function (Player) |
02 | game.Players.PlayerAdded:connect( function (plr) |
03 | plr.Chatted:connect( function (chat) |
04 | if chat = = "SPromo" then |
05 | if plr:GetRankInGroup( 2651783 ) > = 13 then |
06 | if then |
07 |
08 | end |
09 | end |
10 | end |
11 | end ) |
12 | end ) |
13 | end ) |
I need it to find all the players in the final if then section
To obtain any given player's character, use the Character property of the Player object. So, for instance, to get the torso in your function, you could do:
1 | local torso = plr.Character.Torso |
I will fix your script and answer your question.
01 | game.Players.PlayerAdded:connect( function (Player) |
02 | game.Players.PlayerAdded:connect( function (plr) |
03 | plr.Chatted:connect( function (chat) |
04 | if chat = = "SPromo" then |
05 | if plr:GetRankInGroup( 2651783 ) > = 13 then |
06 | if then |
07 |
08 | end |
09 | end |
10 | end |
11 | end ) |
12 | end ) |
13 | end ) |
this is the wrong way to do this, as you have two of the same function it is not needed you can use the same function to use the chat and players.
01 | game.Players.PlayerAdded:connect( function (plr) |
02 | plr.Chatted:connect( function (msg) |
03 | if msg = = "SPromo" then |
04 | if plr:GetRankInGroup( 2651783 ) > = 13 then |
05 | if then |
06 |
07 | end |
08 | end |
09 | end |
10 | end ) |
11 | end ) |
that is the correct way to do your script, you can still use the "plr" portion as well as the "msg" portion.
now, to get the players torso or whatever part you need you should do this,
1 | local torso = plr.Character:findFirstChild( "Torso" ) |
that is just the way I do it, now here is another way to do it
1 | local torso = plr.Character.Torso |
I hope I helped!