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

Gamepass giving hat in game?

Asked by 10 years ago

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

Log in to vote
0
Answered by 10 years ago

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)
Ad

Answer this question