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
local passIdg = 9215890
local MarketplaceService = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
    player:WaitForDataReady()
    if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg or passIdh or passIdi or passIdj or passIdk) then
            player.PlayerGui.GiveDie.Who.Visible = true
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg) then
                    player.StarterGui.GiveDie.Who.Text = "Who will you give the extra standard die to?"
                else
                    print(player.Name .. " does not own the give an extra die pass.")
        end
    end 
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.

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

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.

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.

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:

local mps = game:GetService("MarketplaceService")
local plrs = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local rem = rep:FindFirstChild("ReturnDieMsg")

plrs.PlayerAdded:Connect(function(plr)
    if mps:UserOwnsGamePassAsync(plr.UserId, 9215890 or int or int or int) then --int should be replcaed with your ids
        local sendMsg = false
        if mps:UserOwnsGamePassAsync(plr.UserId, 9215890) then
            sendMsg = true
        end
        rem:FireClient(plr, sendMsg)
    end
end)

Client:

local plr = game:GetService("Players").LocalPlayer
local pgui = plr.PlayerGui
local rep = game:GetService("ReplicatedStorage")
local rem = rep:FindFirstChild("ReturnDieMsg")

rem.OnClientEvent:Connect(function(sendMsg)
    player.PlayerGui.GiveDie.Who.Visible = true
    if sendMsg then
        pgui:FindFirstChild("GiveDie"):FindFirstChild("Who").Text = "Who will you give the extra standard die to?"
    end
end)
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!

game.Players.PlayerAdded:Connect(function(player)
    player:WaitForDataReady()
    if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg or passIdh or passIdi or passIdj or passIdk) then
            player.PlayerGui.GiveDie.Who.Visible = true
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the extra standard die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdh) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the extra multiplier die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdi) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the 20 sided die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdj) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the 20 sided multiplier die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdk) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give a personal die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg and passIdh) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give a standard and multiplier die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg and passIdi) then
                    player.PlayerGui.GiveDie.Text = "Who will you give the standard and standard 20 sided die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg and passIdj) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give a standard die and a 20 sided multiplier to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg and passIdk) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give a standard die and a personal die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdh and passIdi) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give a multiplier and 20 sided die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdh and passIdj) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give a multiplier and 20 sided multiplier die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdh and passIdk) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give a multiplier and personal die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdi and passIdj) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give a 20 sided and 20 sided multiplier die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdi and passIdk) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give a 20 sided and personal die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdj and passIdk) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give a 20 sided multiplier and personal die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg and passIdh and passIdi) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the standard, multiplier and 20 sided die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg and passIdh and passIdj) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the standard, multiplier and 20 sided multiplier die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg and passIdh and passIdk) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the standard, multiplier and personal die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdh and passIdi and passIdj) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the multiplier, 20 sided and 20 sided multiplier die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdh and passIdj and passIdk) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the multiplier, 20 sided and personal die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdi and passIdj and passIdk) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the 20 sided, 20 sided multiplier and personal die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg and passIdh and passIdi and passIdj) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the standard, multiplier, 20 sided and 20 sided multiplier die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg and passIdh and passIdj and passIdk) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the standard, multiplier, 20 sided multiplier and personal die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdh and passIdi and passIdj and passIdk) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give the multiplier, 20 sided, 20 sided multiplier and personal die to?"
                if MarketplaceService:UserOwnsGamePassAsync(player.UserId, passIdg and passIdh and passIdi and passIdj and passIdk) then
                    player.PlayerGui.GiveDie.Who.Text = "Who will you give all the dice to?"
                else        
                    print(player.Name .. " does not own a give a die pass.")
                                                                                                        end
                                                                                                    end
                                                                                                end
                                                                                            end
                                                                                        end
                                                                                    end
                                                                                end
                                                                            end
                                                                        end
                                                                    end
                                                                end
                                                            end
                                                        end
                                                    end
                                                end
                                            end
                                        end
                                    end
                                end
                            end
                        end
                    end
                end 
            end     
        end
    end 
end)
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