Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Find all players?

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)

game.Players.PlayerAdded:connect(function(Player)
game.Players.PlayerAdded:connect(function(plr)
	plr.Chatted:connect(function(chat)
	if chat == "SPromo" then
		if plr:GetRankInGroup(2651783) >= 13 then
		 if then
		
		end
		end
		end
end)
end)
end)

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

2 comments

0

I don't know what you are trying to find here however why do you have 2 of the same functions -_-

0

I have 2 of the same functions as 1 controls the chat and the other controls players

2 answers

✓ Accepted answer

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:

local torso = plr.Character.Torso

I will fix your script and answer your question.

game.Players.PlayerAdded:connect(function(Player)
game.Players.PlayerAdded:connect(function(plr)
    plr.Chatted:connect(function(chat)
    if chat == "SPromo" then
        if plr:GetRankInGroup(2651783) >= 13 then
         if then

        end
        end
        end
end)
end)
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.

game.Players.PlayerAdded:connect(function(plr)
plr.Chatted:connect(function(msg)
if msg == "SPromo" then
if plr:GetRankInGroup(2651783) >= 13 then
if then

end
end
end
end)
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,

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

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

local torso = plr.Character.Torso

I hope I helped!

This discussion is preserved as it was. New answers, comments, and votes are closed.