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

How do I make a gui only visible to gamepass owners?

game.Players.PlayerAdded:Connect(function(Player)
	
	Player.CharacterAdded:Connect(function(Character)
		
		local RushBGui = game.ServerStorage:WaitForChild("GamePasses"):WaitForChild("RussianTransfer"):Clone()
		local mlgPlayers = {"flyerbram002", "MrCrutuBringer", "eleutherios", "ihab123432gamer", "nettimato", "loleris", "TrulyRev", "CishShato", "AxisAngle",}
		local passID = 11260362
		
		if Player.Name == mlgPlayers then
			RushBGui.Parent = Player.PlayerGui.pickweap.Main.RussianWeaps
		end
		
		if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, passID) then
			RushBGui.Parent = Player.PlayerGui.pickweap.Main.RussianWeaps
			
		end
	end)
end)

this script gives gamepass owners or vip players a gui, which works, until they die. How do I get it to continue giving them the gui?

2 comments

0

You can make a remote event for everyone that asks for GUI when they spawn. The server will check if it is the right person.

0

unnecessary

2 answers

✓ Accepted answer

I'm assuming this is a LocalScript because "game.Players.LocalPlayer" is client side only

#First of all, LocalScripts will never do anything when in ServerScriptService. They only function when in ReplicatedFirst, ReplicatedStorage, PlayerScripts, or PlayerGUI.

#Second of all, if your using a LocalScript then there is no reason to use CharacterAdded() since LocalScripts execute when the player joins the game.

3 comments

0

it's a serverscript, I just did localplayer because I was getting frustrated and just did whatever came to my head. I edited the post with an updated script that works until the player dies

0

Try instead of creating a whole new gui just enable and disable gui depending on if they have the pass or not.

0

I fixed the problem by writing a new script, still makes a new gui like before and it's perfect for what I need, but thanks for the help.

I fixed it myself, just wrote another script after gaining a better understanding of marketplaceservice.

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