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

script does not change text in a text label if specific gamepass is owned out of similar passes?

Asked by 4 years ago
01local passIdg = 9215890
02local MarketplaceService = game:GetService("MarketplaceService")
03 
04game.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
14end)

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.

3 answers

Log in to vote
1
Answered by
Subsz 366 Moderation Voter
4 years ago

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

1player.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.

1player.PlayerGui.GiveDie.Who.Text = "Who will you give the extra standard die to?"

Also, it's better not to change PlayerGui from the server.

0
yay this works Jakob_Cashy 79 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

What you should do:

create a remote event in ReplicatedStorage called (whatever you want but in my example) "ReturnDieMsg"

Server:

01local mps = game:GetService("MarketplaceService")
02local plrs = game:GetService("Players")
03local rep = game:GetService("ReplicatedStorage")
04local rem = rep:FindFirstChild("ReturnDieMsg")
05 
06plrs.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
14end)

Client:

01local plr = game:GetService("Players").LocalPlayer
02local pgui = plr.PlayerGui
03local rep = game:GetService("ReplicatedStorage")
04local rem = rep:FindFirstChild("ReturnDieMsg")
05 
06rem.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
11end)
0
subsz already answerd this lol Jakob_Cashy 79 — 4y
Log in to vote
0
Answered by 4 years ago

with Subsz's answer i could do all of this!

01game.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
View all 83 lines...
0
since i own all the gamepasses in my game, it should show the textlabel as "Who will you give all the dice to?" but it just does "Who will you give the standard and multiplier die to?" Jakob_Cashy 79 — 4y
0
the text label is showing all the saying really fast but only stops on the standard and multiplier saying Jakob_Cashy 79 — 4y

Answer this question