Gamepass script never works

It never works and I don’t know why
speed coil gamepass
local MarketPlaceService = game:GetService(“MarketplaceService”)
local GamepassID = 95654024

game.Players.PlayerAdded:Connect(function(player)
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId GamepassID) then
game.ServerStorage.SpeedCoil:Clone().Parent = player:WaitForChild(“Backpack”)
game.ServerStorage.SpeedCoil:Clone().Parent = player:WaitForChild(“StarterGear”)
end
end)

gravity coil gamepass
local MarketPlaceService = game:GetService(“MarketplaceService”)
local GamepassID = 95659937

game.Players.PlayerAdded:Connect(function(player)
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId GamepassID) then
game.ServerStorage.SpeedCoil:Clone().Parent = player:WaitForChild(“Backpack”)
game.ServerStorage.SpeedCoil:Clone().Parent = player:WaitForChild(“StarterGear”)
end
end)

1 Like

Wrong category, put this is #help-and-feedback:scripting-support

Also noticed that in our gravity coil gamepass, you cloned the SpeedCoil instance instead of a gravity coil. It also seems unnecessary to add the tool into StarterGear.

1 Like

MarketPlaceService:UserOwnsGamePassAsync(player.UserId GamepassID)

It might be because you forgot to add a comma:

MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassID)

It looks like there are some syntax errors in the code you provided. Here’s the fixed version:

Copy code

local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassID = 95654024

game.Players.PlayerAdded:Connect(function(player)
  if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then
    game.ServerStorage.SpeedCoil:Clone().Parent = player:WaitForChild("Backpack")
    game.ServerStorage.SpeedCoil:Clone().Parent = player:WaitForChild("StarterGear")
  end
end)

-- gravity coil gamepass
local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassID = 95659937

game.Players.PlayerAdded:Connect(function(player)
  if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then
    game.ServerStorage.SpeedCoil:Clone().Parent = player:WaitForChild("Backpack")
    game.ServerStorage.SpeedCoil:Clone().Parent = player:WaitForChild("StarterGear")
  end
end)

There were a couple of issues with the code:

  1. The MarketPlaceService:UserOwnsGamePassAsync function was being called with two arguments, player.UserId and GamepassID , but there was no comma between them.
  2. The game.ServerStorage.SpeedCoil object was being cloned and added to both the player’s Backpack and StarterGear every time a player joined the game. It might be more appropriate to add different objects to the Backpack and StarterGear , depending on the gamepass that the player owns.