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

Gamepass giving hat in game?

Ok so I have a radio similar to the one in the murder games that is a hat. I want someone to get this item if they have a certain game pass. Does anyone know how to do this. The hat is in the lighting section of the game. Please help! I know how to give a gear but not a hat.

The code I have so far is this but it doesn't work:

local id = 213469246
 
game.Players.PlayerAdded:connect(function(player)
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, id) then 
        player.CharacterAdded:connect(function(character)
            game.Lighting.Radio:clone().Parent = character
        end)
    end
end)

1 answer

Try this m8:

wait(2)

gpid = 213469246
hats = {"Radio"}

GPS = game:GetService("GamePassService")
function respawned(char)
local player = game.Players:FindFirstChild(char.Name)
if char:FindFirstChild("Head") ~= nil then
if GPS:PlayerHasPass(player, gpid) then
for i = 1,#hats do
game.Lighting:FindFirstChild(hats[i]):Clone().Parent = char
end
else
end
end
end
game.Workspace.ChildAdded:connect(respawned)

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