Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Find all players?

Asked by 9 years ago

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)

01game.Players.PlayerAdded:connect(function(Player)
02game.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
11end)
12end)
13end)

I need it to find all the players in the final if then section

0
I don't know what you are trying to find here however why do you have 2 of the same functions -_- KingLoneCat 2642 — 9y
0
I have 2 of the same functions as 1 controls the chat and the other controls players Conmmander 479 — 9y

2 answers

Log in to vote
3
Answered by 9 years ago

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:

1local torso = plr.Character.Torso
Ad
Log in to vote
0
Answered by
IcyEvil 260 Moderation Voter
9 years ago

I will fix your script and answer your question.

01game.Players.PlayerAdded:connect(function(Player)
02game.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
11end)
12end)
13end)

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.

01game.Players.PlayerAdded:connect(function(plr)
02plr.Chatted:connect(function(msg)
03if msg == "SPromo" then
04if plr:GetRankInGroup(2651783) >= 13 then
05if then
06 
07end
08end
09end
10end)
11end)

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,

1local torso = plr.Character:findFirstChild("Torso")

that is just the way I do it, now here is another way to do it

1local torso = plr.Character.Torso

I hope I helped!

Answer this question