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

Gui visible only for gamepass owners?

Asked by 4 years ago
 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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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
0
Thanks! the script is local or ? fortesss7 40 — 4y
0
Server FixRobloxz 61 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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)
0
Thanks! fortesss7 40 — 4y
0
Can you accept or upvote my answer? GooierApollo664 183 — 4y

Answer this question