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

Gui visible only for gamepass owners?

 local id = 6741728
game.Players.PlayerAdded:connect(function(player)
    if local HasPass = Game:GetService("GamePassService"):PlayerHasPass(player, id) then
player:findFirstChild("PlayerGui").VIPgui.Visible = true else player:findFirstChild("PlayerGui").VIPgui.Visible = false
local x = Instance.new("Message",Workspace)
x.Text = player.Name .. (HasPass and " has" or " doesn't have").. " the game pass!"
wait(2)
x:Remove()
end
end)

It won't work! any ideas ? :/

2 answers

✓ Accepted answer

You make the gui in the server storage so exploiters can't get the gui. Maybe this thing will work:

local bruh = game.ServerStorage:WaitForChild("YourGuiNameAhhh") --Your Gui
local ok = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(Player)
	if ok:UserOwnsGamePassAsync(Player.UserId, YourIdHereXdOof) then
		local meh = bruh:Clone()
		meh.Parent = Player.PlayerGui
	end
end

2 comments

0

Thanks! the script is local or ?

0

Server

If that's full code, then the issue is, that you don't have HasPass Defined anywhere, so there is no way for conditional to be true I think.

-- Server Script
local remote = Instance.new("RemoteEvent", game.ReplicatedStorage)

local id = 6741728
game.Players.PlayerAdded:connect(function(player)
    if Game:GetService("GamePassService"):PlayerHasPass(player, id) then

	local HasPass = Game:GetService("GamePassService"):PlayerHasPass(player, id)

	player:findFirstChild("PlayerGui").VIPgui.Visible = true 

    else 			

	player:findFirstChild("PlayerGui").VIPgui.Visible = false

	local x = Instance.new("Message",Workspace)
	x.Text = player.Name .. (HasPass and " has" or " doesn't have").. " the game pass!"
	wait(2)
	x:Remove()

	end
end)

2 comments

0

Thanks!

0

Can you accept or upvote my answer?

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