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

Finding a player in normal script? [UNSOLVED]

Asked by 9 years ago

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?

0
Note: This isn't possible with FilteringEnabled (which is, in general, recommended) BlueTaslem 18071 — 9y
0
I added a way to do it with scripts then. However I recommend using FilteringEnabled. PiggyJingles 358 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

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;
0
It doesn't work. Grenaderade 525 — 9y
0
Is this a localscript or script? PiggyJingles 358 — 9y
0
Script. Grenaderade 525 — 9y
0
I want it to do it to everyone. Grenaderade 525 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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

Answer this question