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

Why Does This Not Work?

Asked by 9 years ago

I put this LocalScript into Startergui. Basically, I want a TextButton to be visible when a Player owns a Gamepass.

game.Players.PlayerAdded:connect(function(plr)
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr,205849491) then
        script.Parent["Change Team GUI"].SwitchTeam.Judge.Visible = true
    else
        script.Parent["Change Team GUI"].SwitchTeam.Judge.Visible = false
    end
end)
1
PlayerAdded doesn't work in localscripts. I'll help you later if no-one made an answer. Thetacah 712 — 9y
0
:l Ok ScriptingHelpersALT 20 — 9y
1
You could use ChildAdded on game.players. I can't make you the script right now though. Try seeing if you can make the script with childadded. Thetacah 712 — 9y

1 answer

Log in to vote
0
Answered by
Diitto 230 Moderation Voter
9 years ago

Thetacah answered this question, though he had no time to make an example script.

A working script:

local Judge=script.Parent["Change Team GUI"].SwitchTeam.Judge;--// Simplified.
game:service'Players'.childAdded:connect(function(Player)
    if(
        Player:isA'Player'and 
        game:GetService("MarketplaceService"):PlayerOwnsAsset(
            Player,
            205849491
        )
    ) then
        Judge.Visible = true
    else
        Judge.Visible = false
    end
end);
0
I put that LocalScript into StarterGui but it didn't work. ScriptingHelpersALT 20 — 9y
Ad

Answer this question