Speed Gamepass and Trail Gamepass Not working!

im making a gamepass that gives you twice speed but it seems that it doesnt work
here is the id for speed = 17440176
id for trail = 16075657

local sided script for speed

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamePassID = 17440176 -- Change this to your game pass ID
local player = Players.LocalPlayer
-- Function to prompt purchase of the game pass

script.Parent.BuyButton.MouseButton1Click:Connect(function()
	MarketplaceService:PromptGamePassPurchase(player,gamePassID)
end)

serversided script for speed

local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")

local SPEED_PASS_ID = 17440176

local function purchaseFinished(player, gamePassId, isPurchased)
	if isPurchased and gamePassId == SPEED_PASS_ID then
		player.Character.Humanoid.WalkSpeed = 32
	end
end

local function playerAdded(player)
	-- Reverse function order to reduce UOGPA calls
	if MarketplaceService:UserOwnsGamePassAsync(player.UserId, SPEED_PASS_ID) then
		player.CharacterAdded:Connect(function (character)
			character:WaitForChild("Humanoid").WalkSpeed = 32
		end)
	end
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(purchaseFinished)
Players.PlayerAdded:Connect(playerAdded)

for _, player in ipairs(Players:GetPlayers()) do
	playerAdded(player)
end
local sided trail

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamePassID = 16075657 -- Change this to your game pass ID
local player = Players.LocalPlayer
-- Function to prompt purchase of the game pass

script.Parent.BuyButton.MouseButton1Click:Connect(function()
	MarketplaceService:PromptGamePassPurchase(player,gamePassID)
end)
server sided trail
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")

local TRAIL_PASS_ID = 16075657

local function purchaseFinished(player, gamePassId, isPurchased)
	if isPurchased and gamePassId == TRAIL_PASS_ID then
		local character = player.Character or player.CharacterAdded:Wait()
		local att0 = Instance.new("Attachment")
		att0.Name = "att0"
		att0.Parent = character.Head
		local att1 = Instance.new("Attachment")
		att1.Name = "att1"
		att1.Parent = character.HumanoidRootPart
		local trail = game.ServerStorage.Trail:Clone()
		trail.Parent = character.Head
		trail.Attachment0 = att0
		trail.Attachment1 = att1
		player.PlayerGui.MainMenuGui.MonetizationFrame.PassFrame.Product5.BuyButton.Text = "Owned"
		player.PlayerGui.MainMenuGui.MonetizationFrame.PassFrame.Product5.BuyButton.Selectable = false
		player.PlayerGui.MainMenuGui.MonetizationFrame.PassFrame.Product5.BuyButton.AutoButtonColor = false
	end
end

local function playerAdded(player)
	-- Reverse function order to reduce UOGPA calls
	if MarketplaceService:UserOwnsGamePassAsync(player.UserId, TRAIL_PASS_ID) then
		player.CharacterAdded:Connect(function (character)
			local att0 = Instance.new("Attachment")
			att0.Name = "att0"
			att0.Parent = character.Head
			local att1 = Instance.new("Attachment")
			att1.Name = "att1"
			att1.Parent = character.HumanoidRootPart
			local trail = game.ServerStorage.Trail:Clone()
			trail.Parent = character.Head
			trail.Attachment0 = att0
			trail.Attachment1 = att1
			player.PlayerGui.MainMenuGui.MonetizationFrame.PassFrame.Product5.BuyButton.Text = "Owned"
			player.PlayerGui.MainMenuGui.MonetizationFrame.PassFrame.Product5.BuyButton.Selectable = false
			player.PlayerGui.MainMenuGui.MonetizationFrame.PassFrame.Product5.BuyButton.AutoButtonColor = false
		end)
	end
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(purchaseFinished)
Players.PlayerAdded:Connect(playerAdded)

for _, player in ipairs(Players:GetPlayers()) do
	playerAdded(player)
end

pls help thx and there arent any error too

1 Like

Why couldn’t you just encase both your ServerScripts into 1 main script?

I’d recommend adding print() statements in your purchaseFinished functions, so that you know it’s being outputted back as the script detecting the purchase :thinking:

3 Likes

thx but i fixed it anyways before you but ill still put you a solution!