Make a gui appear when player owns a game pass

I’m making a game pass that allows you to see a curtain gui. It works fine, until 2 people are in the server that owns the gamepass. Also, when you die the gui disappears. Here’s the script:

local PassId = 11379241


game.Players.PlayerAdded:connect(function(p)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(p.UserId, PassId) then
		    	
		game.StarterGui.speed.Frame.Visible = not game.StarterGui.speed.Frame.Visible
		
    end
  end)

Here is what it looks like in studio:
Screen Shot 2020-08-22 at 7.49.01 PM
Screen Shot 2020-08-22 at 7.49.05 PM
I assume it’s this line:

game.StarterGui.speed.Frame.Visible = not game.StarterGui.speed.Frame.Visible

If you see anything wrong please let me know.

4 Likes

When you make a change to game.StarterGui the changes are universal, therefore if speed.Frame is Visible = false by default, by the time the second player joins you will have done a full cycle. Lets make some small edits to your code to make it more versatile.

local PassId = 11379241
game.Players.PlayerAdded:connect(function(p)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(p.UserId, PassId) then
		p.PlayerGui.speed.Frame.Visible = true
	else
		return
	end
	p.CharacterAdded:Connect(function()
		p.PlayerGui:WaitForChild("speed"):WaitForChild("Frame").Visible = true
	end)
end)

All we’re doing is having this target only the player, preventing the gui from cycling back to false, and preventing the gui from resetting when the player dies.

7 Likes

Thanks. It still resets if you respawn, not 100% sure why.

For some reason it completely stopped showing, it shows in studio though. Any idea why?

I edited my original reply with an alternative solution to the matter, could you test that out and report back - reverting the settings back to normal could also be beneficial.

1 Like

Screen Shot 2020-08-22 at 8.50.39 PM
There’s an error at the end, how do I fix that? I tried removing the bracket.

There should be two ends at the bottom of the script, make sure both of them have closing parenthesees.

Sadly it still doesn’t show the gui. I’m not 100% sure why.

I reverted the settings back to normal, it’s no longer showing the gui. Any idea why?

Not working for me either, how could I fix this?

1 Like

disable resetonspawn and it will be fixed i think @CowboySticky @Chai_rbf

1 Like