Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why Does This Not Work?

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)

3 comments

1

PlayerAdded doesn't work in localscripts. I'll help you later if no-one made an answer.

0

:l Ok

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.

1 answer

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);

1 comment

0

I put that LocalScript into StarterGui but it didn't work.

This discussion is preserved as it was. New answers, comments, and votes are closed.