game.Players.PlayerAdded:connect(function(plyr) local gamePassService = game:GetService("GamePassService") if gamePassService:PlayerHasPass(plyr,258305700) then plyr.Character.PlayerGui -- eg (this line I want to access the StarterGUI) end end)
Basically I want my script above to access the Player's StarterGUI, But how do I do it?
this script is in serverscriptservice.
Its prob an easy fix. Im still learning about the hierarchy of roblox. Thanks, ~bubs
So anything that goes in the StarterGui goes into the player's PlayerGui. PlayerGui is a member of the plyr, plyr is a member of Players, and Players is a member of game. Visual: http://i.imgur.com/9qfxRtB.png
To fix your script:
game.Players.PlayerAdded:connect(function(plyr) local gamePassService = game:GetService("GamePassService") if gamePassService:PlayerHasPass(plyr,258305700) then playerGui = plyr.PlayerGui -- assigns a variable to the player's playergui. you could not assign it a variable if you want by simply saying, "plyr.PlayerGui" end end)
game.Players.PlayerAdded:connect(function(plyr) local gamePassService = game:GetService("GamePassService") if gamePassService:PlayerHasPass(plyr,258305700) then plyr.Character.PlayerGui -- the PlayerGui isn't in the character, its in the player itself end end)
so the fix is
game.Players.PlayerAdded:connect(function(plyr) local gamePassService = game:GetService("GamePassService") if gamePassService:PlayerHasPass(plyr,258305700) then plyr.PlayerGui -- the PlayerGui isn't in the character, its in the player itself end end)