Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How do you make a gamepass so when a player buys it they wear a hat when they join the game?

Asked by 9 days ago

Im trying to make a gamepass that makes it when a player buys it they wear a hat when they join the game but i cant get around his problem i tried fixing the script but i think i just made it worse since im a beginner at scripting.

local MarketPlaceService = game:GetService('MarketplaceService')
local GamepassId = 11001479

game.Players.PlayerAdded:Connect(function(PlayerWhoJoined)
    PlayerWhoJoined.CharacterAdded:Connect(function()
        if MarketPlaceService:UserOwnsGamePassAsync(PlayerWhoJoined.UserId, GamepassId) then
            local BetaHat = script:FindFirstChild('Accessory'):Clone()
            BetaHat.Parent = PlayerWhoJoined.Character
        end
    end)
    MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(Player,GamePassId,Purchased)
        if GamePassId == GamepassId and Purchased == true then
            local BetaHat = script:FindFirstChild('Accessory'):Clone()
            BetaHat.Parent = PlayerWhoJoined.Character
        end
    end)
end)


0
This script looks good to me ! Are there any errors or warning pertaining to your code? Tizzel40 225 — 9d
0
Make it print something if they have the game pass , and see if it prints anything. Tizzel40 225 — 9d
0
idk it gives me this error - ServerScriptService.HatGamepass:7: attempt to index nil with 'Clone' DataCordz 0 — 9d

Answer this question