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

Finding a player in normal script? [UNSOLVED]

I made a script to access a player's PlayerGui, the PlayerGui part is okay, but this part isn't, and I don't know why:

p = game.Players:GetPlayers()
int = p.PlayerGui.Intermission.TextLabel

Could anyone help?

2 comments

0

Note: This isn't possible with FilteringEnabled (which is, in general, recommended)

0

I added a way to do it with scripts then. However I recommend using FilteringEnabled.

2 answers

You are getting "PlayerGui" of a table which is nil since :GetPlayers() returns all players in the game in a table.

LocalScript:

You need to reference the local player with game.Players.LocalPlayer:

local p = game.Players.LocalPlayer;
local int = p.PlayerGui.Intermission.TextLabel;

Script:

You can reference the player instead with game.Players[playername]

local playername = "PiggyJingles";
local p = game.Players[playername];
local int = p.PlayerGui.Intermission.TextLabel;

4 comments

0

It doesn't work.

0

Is this a localscript or script?

0

Script.

0

I want it to do it to everyone.

You can use a loop to iterate through the players to find the player you want.

local player = "Grenaderade"
for i,v in pairs(game.Players:GetPlayers())
if v.name == player then
player = v
break
end
end

Alternatively, you can use the PlayerAdded() event

game.Players.PlayerAdded:connect(function(player)
print(player)
end

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