Hello!
-
What do you want to achieve? Keep it simple and clear!
I created and scripted a gamepass that gives anyone who buys it a sword. -
What is the issue? Include screenshots / videos if possible!
The gamepass works fine but the issue is that whenever someone tries to equip the sword it teleports them back I need help with fixing this issue. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried looking on the Developer Hub but still couldn’t fix the issue.
I will put all the gamepass scripts incase you might think there’s something wrong with any of them also it’d be nice if you can tell me if there’s any improvements that I can make to the scripts.
PromptPurchase Handler
local MarketPlaceService = game:GetService("MarketplaceService")
local gamePassID = 8609174
local function promptPurchase()
local player = game.Players.LocalPlayer
local havethePass = false
local success, errormessage = pcall(function()
havethePass = MarketPlaceService:UserOwnsGamePassAsync(player, gamePassID)
end)
if havethePass == true then
print("Player has the give sword gamepass")
MarketPlaceService:PromptGamePassPurchase(player, gamePassID)
else
MarketPlaceService:PromptGamePassPurchase(player, gamePassID)
end
end
The gamepass handler
local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sword = ReplicatedStorage:WaitForChild("ClassicSword")
local gamePassID = 8609174
MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasePassID, purchaseSuccess)
if purchaseSuccess == true and purchasePassID == gamePassID then
print(player.Name.." has the give sword gamepass")
Sword.Parent = player.Character
end
end)
Giving the players the sword when they join again
local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sword = ReplicatedStorage:WaitForChild("ClassicSword")
local gamePassID = 8609174
game.Players.PlayerAdded:Connect(function(player)
wait(5)
local char = game.Workspace:FindFirstChild(player.Name)
local hasPass = false
local success, errormessage = pcall(function()
havethePass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
end)
if havethePass == true then
print(player.Name.." has the give sword gamepass purchased")
Sword.Parent = char
end
end)