01 | local passIdg = 9215890 |
02 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
03 |
04 | game.Players.PlayerAdded:Connect( function (player) |
05 | player:WaitForDataReady() |
06 | if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg or passIdh or passIdi or passIdj or passIdk) then |
07 | player.PlayerGui.GiveDie.Who.Visible = true |
08 | if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg) then |
09 | player.StarterGui.GiveDie.Who.Text = "Who will you give the extra standard die to?" |
10 | else |
11 | print (player.Name .. " does not own the give an extra die pass." ) |
12 | end |
13 | end |
14 | end ) |
pass id h through k are other "give a die" passes
what i wanted this script to do is when pass id g was owned it would change the text in a text label to "Who will you give the extra standard die to?" but it does not.
First of all, please do not use WaitForDataReady() as it is deprecated.
What you're doing wrong inside your script while changing the text is that you're doing
1 | player.StarterGui.GiveDie.Who.Text = "Who will you give the extra standard die to?" |
this is wrong because a player does not have a child name StarterGui. you're mistaking it for PlayerGui.
1 | player.PlayerGui.GiveDie.Who.Text = "Who will you give the extra standard die to?" |
Also, it's better not to change PlayerGui from the server.
What you should do:
create a remote event in ReplicatedStorage called (whatever you want but in my example) "ReturnDieMsg"
Server:
01 | local mps = game:GetService( "MarketplaceService" ) |
02 | local plrs = game:GetService( "Players" ) |
03 | local rep = game:GetService( "ReplicatedStorage" ) |
04 | local rem = rep:FindFirstChild( "ReturnDieMsg" ) |
05 |
06 | plrs.PlayerAdded:Connect( function (plr) |
07 | if mps:UserOwnsGamePassAsync(plr.UserId, 9215890 or int or int or int) then --int should be replcaed with your ids |
08 | local sendMsg = false |
09 | if mps:UserOwnsGamePassAsync(plr.UserId, 9215890 ) then |
10 | sendMsg = true |
11 | end |
12 | rem:FireClient(plr, sendMsg) |
13 | end |
14 | end ) |
Client:
01 | local plr = game:GetService( "Players" ).LocalPlayer |
02 | local pgui = plr.PlayerGui |
03 | local rep = game:GetService( "ReplicatedStorage" ) |
04 | local rem = rep:FindFirstChild( "ReturnDieMsg" ) |
05 |
06 | rem.OnClientEvent:Connect( function (sendMsg) |
07 | player.PlayerGui.GiveDie.Who.Visible = true |
08 | if sendMsg then |
09 | pgui:FindFirstChild( "GiveDie" ):FindFirstChild( "Who" ).Text = "Who will you give the extra standard die to?" |
10 | end |
11 | end ) |
with Subsz's answer i could do all of this!
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | player:WaitForDataReady() |
03 | if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg or passIdh or passIdi or passIdj or passIdk) then |
04 | player.PlayerGui.GiveDie.Who.Visible = true |
05 | if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg) then |
06 | player.PlayerGui.GiveDie.Who.Text = "Who will you give the extra standard die to?" |
07 | if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdh) then |
08 | player.PlayerGui.GiveDie.Who.Text = "Who will you give the extra multiplier die to?" |
09 | if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdi) then |
10 | player.PlayerGui.GiveDie.Who.Text = "Who will you give the 20 sided die to?" |
11 | if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdj) then |
12 | player.PlayerGui.GiveDie.Who.Text = "Who will you give the 20 sided multiplier die to?" |
13 | if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdk) then |
14 | player.PlayerGui.GiveDie.Who.Text = "Who will you give a personal die to?" |
15 | if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg and passIdh) then |