Im attempting to create a script where it checks the name of a player in the team. It’ll then print that value as the winner. I tried to create use this
game.Teams.Players:FindFirstChildOfClass(“Player”).Name
However it gives the error " [ServerScriptService.ServerControl:47: attempt to index nil with Name"
Is their an alternative to find the Player
You should be using Team:GetPlayers()
instead
This doesn’t work in fact (30 Characters)
Crrustyy
(boblox_man)
June 23, 2020, 3:35pm
#4
Are you looking for a script where it finds one individual player, or a script where you get the players in a certain team?
One player in one team. (30 Characters)
Slazai
(Slazai)
June 23, 2020, 4:02pm
#6
Players aren’t parented to teams. That’s why game.Teams.Players:FindFirstChildOfClass(“Player”)
returns nil
.
So you should use Team:GetPlayers()
, this returns Player
objects whose properties are equal to Team
in an array.
e.g.:
local player
for i,plr in ipairs(Team:GetPlayers()) do
if plr.Name == SOME_NAME then
player = plr
break
end
end
2 Likes