Hi out there I made a gamepass script that is supposed to give you a sword after purchasing it but it ain’t giving you the sword and I haven’t found an error in the script yet. Can anyone help me with this?
Gamepass Checker Script (This script is located in the ServerScriptService)
local MarketplaceService = game:GetService(“MarketplaceService”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local Sword = ReplicatedStorage:WaitForChild(“ClasssicSword”)
local gamePassID = 11167961
game.Players.PlayerAdded:Connect(function(player)
wait(1)
local char = game.Workspace:FindFirstChild(player.name)
local hasPass = false
local success , message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId , gamePassID)
if hasPass == true then
print ("player aldready has the give sword gamepass")
Sword.Parent = char
end
end)
end)
Gamepass Prompter Script (This script is located in starter player scripts)
local MarketplaceService = game:GetService(“MarketplaceService”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local Sword = ReplicatedStorage:WaitForChild(“ClasssicSword”)
local gamePassID = 11167961
game.Players.PlayerAdded:Connect(function(player)
wait(1)
local char = game.Workspace:FindFirstChild(player.name)
local hasPass = false
local success , message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId , gamePassID)
if hasPass == true then
print ("player aldready has the give sword gamepass")
Sword.Parent = char
end
end)
end)
GamePass Handeler Script (Its located in the ServerScriptService in my Workspace)
local MarketplaceService = game:GetService(“MarketplaceService”)
local gamePassID = 11167961
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local Sword = ReplicatedStorage:WaitForChild(“ClasssicSword”)
MarketplaceService.PromptGamePassPurchaseFinished:Connect (function(player , purchasePassID,purchaseSuccess)
if purchaseSuccess == true and purchasePassID == gamePassID then
print (player.name… “purchased the give sword gamepass”)
Sword.Parent = player.Character
end
end)