I’m gonna make a gamepass like if you buy it you will have instantly have the hat
Someone can help me?
Heres my script
local MarketplaceService = game:GetService(‘MarketplaceService’)
local GAMEPASSID = 000000
local function AddHatToCharacter(Character)
– Run code to add hat.
script:FindFirstChildOfClass(‘Accessory’):Clone().Parent = Character
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(Player, GamePassId, Purchased)
if Purchased then – They actually bought it, and didn’t click ‘Cancel’
if GamePassId == GAMEPASSID then – It’s the hat gamepass
Player.CharacterAdded:Connect(function(Character)
AddHatToCharacter(Character)
end)
if Player.Character then
AddHatToCharacter(Player.Character)
end
end
end
end)
game:GetService(‘Players’).PlayerAdded:Connect(function(Player)
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GAMEPASSID) then
Player.CharacterAdded:Connect(function(Character)
AddHatToCharacter(Character)
end)
end
end)
local MarketplaceService = game:GetService(‘MarketplaceService’)
local GAMEPASSID = 000000
local function AddHatToCharacter(Character)
– Run code to add hat.
script:FindFirstChildOfClass(‘Accessory’):Clone().Parent = Character
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(Player, GamePassId, Purchased)
if Purchased then – They actually bought it, and didn’t click ‘Cancel’
if GamePassId == GAMEPASSID then – It’s the hat gamepass
Player.CharacterAdded:Connect(function(Character)
AddHatToCharacter(Character)
end)
game:GetService(‘Players’).PlayerAdded:Connect(function(Player)
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GAMEPASSID) then
Player.CharacterAdded:Connect(function(Character)
AddHatToCharacter(Character)
end)
end
end)
local MarketplaceService = game:GetService("MarketplaceService")
local GAMEPASSID = 000000
function AddHatToCharacter( chr )
local newHat = x--here is reference proto newHat
newHat.Parent= chr
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(Player, GamePassId, Purchased)
if Purchased then
if GamePassId==GAMEPASSID then
AddHatToCharacter(Player.Character)
end
end
end)
game.Players.PlayerAdded:Connect(function(Player)
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GAMEPASSID) then
Player.CharacterAppearanceLoaded:Connect(function(chr)
AddHatToCharacter(chr)
end)
end
end)
local MarketPlaceService = game:GetService('MarketplaceService')
local GamepassId = 0
game.Players.PlayerAdded:Connect(function(PlayerWhoJoined)
PlayerWhoJoined.CharacterAdded:Connect(function()
if MarketPlaceService:UserOwnsGamePassAsync(PlayerWhoJoined.UserId, GamepassId) then
local Cloned_Item = script:FindFirstChild('Accessory'):Clone()
Cloned_Item.Parent = PlayerWhoJoined.Character
end
end)
MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(Player,GamePassId,Purchased)
if GamePassId == GamepassId and Purchased == true then
local Cloned_Item = script:FindFirstChild('Accessory'):Clone()
Cloned_Item.Parent = PlayerWhoJoined.Character
end
end)
end)