This is my script and for some reason the gamepass wont save, can someone please fix it:
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) ------ Your Gamepass ID here
if ownsGamepass then
local sword = game:GetService("ReplicatedStorage"):WaitForChild("SpeedCoil"):Clone() -------- Change "ClassicSword" to your tool's name
sword.Parent = player.Backpack
end
end
local Button = script.Parent
local gamePassId = script.Parent.GamepassId
local Tool = game:GetService("ReplicatedStorage"):WaitForChild("SpeedCoil")
local MarketplaceService = game:GetService("MarketplaceService")
local Player = game:GetService("Players").LocalPlayer
Button.MouseButton1Click:connect(function()
if Player then
local ownsGamepass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamePassId.Value)
if ownsGamepass then
Tool:Clone().Parent = Player.Backpack
Tool:Clone().Parent = Player.StarterGear
else
MarketplaceService:PromptGamePassPurchase(Player, gamePassId.Value)
end
end
end)
I suggest you add it by PlayerAdded in a ServerScript;
local gamePassId = --gamepassid
local Tool = game:GetService("ReplicatedStorage"):WaitForChild("SpeedCoil")
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Players.CharacterAdded:Connect(function(Char)
if Player then
local ownsGamepass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamePassId.Value)
if ownsGamepass then
Tool:Clone().Parent = Player.Backpack
Tool:Clone().Parent = Player.StarterGear
else
MarketplaceService:PromptGamePassPurchase(Player, gamePassId.Value)
end
end
end)
end)
local Button = script.Parent
local gamePassId = 38706262 -- Your gamepass id
local Tool = game:GetService("ReplicatedStorage"):WaitForChild("SpeedCoil")
local MarketplaceService = game:GetService("MarketplaceService")
local Player = game:GetService("Players").LocalPlayer
Button.MouseButton1Click:connect(function()
if Player then
local ownsGamepass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamePassId)
if ownsGamepass then
Tool:Clone().Parent = Player.Backpack
Tool:Clone().Parent = Player.StarterGear
else
MarketplaceService:PromptGamePassPurchase(Player, gamePassId)
end
end
end)
local MarketplaceSvc = game:GetService("MarketplaceService")
local GamepassId = 0 --put your gamepass id here
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(model)
if MarketplaceSvc:UserOwnsGamePassAsync(plr.UserId, GamepassId) then
local sword = game:GetService("ReplicatedStorage"):WaitForChild("SpeedCoil"):Clone() -- Change "ClassicSword" to your tool's name
sword.Parent = plr.Backpack
end
end)
end)