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

Game Pass Script Problems?

Asked by 9 years ago
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

2 answers

Log in to vote
1
Answered by
AmiracIe 175
9 years ago

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)

Ad
Log in to vote
1
Answered by 9 years ago
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)

Answer this question