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

My Premium Nametag doesn't work?

Asked by 6 years ago

Hi, my premium nametag dont work I don't know why here is the script :

local id = 1082986441
local billboardgui = script:WaitForChild("BillboardGui")

game.Players.PlayerAdded:connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
      local b = billboardgui:Clone()
b.Parent = game:GetService("Players").LocalPlayer.Character
    else
        print(player.Name .. " doesn't have the game pass...")
    end
end)

with a billboardgui inside of the script but ingame it's doesn't show the * PREMIUM * :( Thanks for the help.

0
This will only show for the local player, you should test this on a normal script  Leamir 3138 — 6y

4 answers

Log in to vote
0
Answered by 6 years ago

Hi! PlayerHasPass is no longer supported by ROBLOX, use UserOwnsGamePassAsync instead, same with MarketplaceService, rather than GamepassService. player is also no longer a valid parameter, use player.UserId instead.

Your script should be:

local id = 1082986441
local billboardgui = script:WaitForChild("BillboardGui")

game.Players.PlayerAdded:connect(function(player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id) then 
      local b = billboardgui:Clone()
b.Parent = game:GetService("Players").LocalPlayer.Character
    else
        print(player.Name .. " doesn't have the game pass...")
    end
end)

Hope this works!

0
doesn't work AzbenNR 0 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

The PlayerHasPass method is broken because of the new game pass updates. As previously mentioned, MarketplaceService:UserOwnsGamePassAsync() should be used instead. Another problem is you were using LocalPlayer from a server script, which LocalPlayer is nil on. Since you were using PlayerAdded, use its parameter instead.

wait()
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local id = 1082986441
local billboardgui = script.BillboardGui

local function hasPass(plr)
    return MarketplaceService:UserOwnsGamePassAsync(plr.UserId, id)
    -- return true if they have the id, return false if not 
end

game.Players.PlayerAdded:Connect(function(player) -- :connect is deprecated, use :Connect. also, this is the player, use this and not LocalPlayer
    player.CharacterAdded:Connect(function(character) -- wait for character! 
        if hasPass(player) then -- if they have the pass
            local b = billboardgui:Clone()
            b.Parent = character
        else
            print(player, "doesn't have the game pass...")
        end
    end)
end)


Log in to vote
-1
Answered by
Leamir 3138 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Hello, AzbenNR!

local id = 1082986441
local billboardgui = script:WaitForChild("BillboardGui")

game.Players.PlayerAdded:connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then
      local b = billboardgui:Clone()
      b.Parent = player.Character
      b.Parent.Position = player.Character.Head.Position + Vector3.new(0, 1, 0) -- Sets the bilboard gui position at the player's head position(with a offset)
    else
        print(player.Name .. " doesn't have the game pass...")
    end
end)

(To make the bilboard gui be shown to all players, just plcae the script on a normal script)

Good Luck with your games

0
doesn't work on a normal script :/ AzbenNR 0 — 6y
Log in to vote
-2
Answered by 6 years ago

Roblox replaced the GamePassService with Marketplace Service.

Try this:

local billboardGui = game:GetService("ServerStorage"):WaitForChild("Gui")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 00000) then 
        local clonedGui = billboardGui:Clone()
        clonedGui.Parent = game.Workspace:WaitForChild(player.Name).Head
        clonedGui.TextLabel.Text = "Premium"
        player:IsLoaded()
    end

    end)
end)

Replace the 00000 with your Gamepass ID and put the script along with the billboard gui and text in Server Storage. Also change the "Gui" in the first line to whatever the name of the billboard gui is! Hope this helped! -tawk1215

0
doesn't work AzbenNR 0 — 6y

Answer this question