My gamepass wont save

my code:local button = script.Parent
local player = game.Players.LocalPlayer
local gamePassId = script.Parent.GamepassId

button.MouseButton1Click:connect(function()
if player then
game:GetService(“MarketplaceService”):PromptGamePassPurchase(player, gamePassId.Value)
local player = game.Players.LocalPlayer
local ownsGamepass = game:GetService(“MarketplaceService”):UserOwnsGamePassAsync(player.UserId,38706262)

	if ownsGamepass then
		local sword = game:GetService("ReplicatedStorage"):WaitForChild("SpeedCoil"):Clone()
		sword.Parent = player.Backpack
	end
end

end)

i am quite new to coding so i need your guy’s help

If you are new to marketplace service I would suggest you look at the API

This will tell you all about the marketplaceService and to check if the player owns the gamepass