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?
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?
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;
It doesn't work.
Is this a localscript or script?
Script.
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.
2 comments
Note: This isn't possible with FilteringEnabled (which is, in general, recommended)
I added a way to do it with scripts then. However I recommend using FilteringEnabled.