Trail Gamepass, Gamepass not recognizing

Hey,

I am trying to make a trail gamepass but it doesn’t seem to recognize my gamepass. This is my Trail gamepass script where it checks for the gamepass.

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
	wait(2)
	local trail = char.Head.Trail
	local MarketPlaceService = game:GetService("MarketplaceService")
	local UserId = player.UserId
	local PlayerBoughtThisGamepass = MarketPlaceService:UserOwnsGamePassAsync(UserId, 16160354) -- Change to gamepassid
	
	if PlayerBoughtThisGamepass then
		trail.Enabled = true
		trail.Lifetime = 5
	else
		trail.Enabled = false
	end
end)

I hope someone can help me, already thanks!

1 Like

Have you got any errors in the output or in the console?

Maybe the trail isn’t on the head yet.

Nope, no errors.

Boring extra text for requirements

You’re using 2 Events, and 1 if statement to check but all I see from the closing lines are these:

Could you try adding another end) after the first one?

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
	wait(2)
    local trail1 = game.ReplicatedStorage.Trail -- or replace with the path to the trail
	local trail = char.Head.Trail
	local MarketPlaceService = game:GetService("MarketplaceService")
	local UserId = player.UserId
	local PlayerBoughtThisGamepass = MarketPlaceService:UserOwnsGamePassAsync(UserId, 16160354) -- Change to gamepassid
	
	if PlayerBoughtThisGamepass then
		trail.Enabled = true
		trail.Lifetime = 5
	else
		trail.Enabled = false
	end
end)
end)

Try this:

if (MarketPlaceService:UserOwnsGamePassAsync(UserId, 16160354)) then
    --The rest of the script here
end

I forgot to add on to the script. But the trail wouldnt automatically be a thing on the head, you have to clone it first.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		wait(2)
		local trail = char.Head.Trail
		local MarketPlaceService = game:GetService("MarketplaceService")
		local UserId = player.UserId
		local PlayerBoughtThisGamepass = MarketPlaceService:UserOwnsGamePassAsync(UserId, 16160354) -- Change to gamepassid

		if PlayerBoughtThisGamepass then
			trail.Enabled = true
			trail.Lifetime = 5
		else
			trail.Enabled = false
		end
	end)
end)

Did that, doesnt make any difference.

It does make a difference, you didn’t end the first function.

Are you getting any errors firstly?

Oops, didn’t see that you already checked and no errors, maybe try printing the contents of the PlayerBoughtThisGamePass variable? @Coolebooster

I mean I tried it but it didnt change anything

@Coolebooster try to put the trail in the RepicatedStorage and then write this in the script:

local trail = game.ReplicatedStorage:WaitForChild("Trail") --Change trail with the name of your trail

if PlayerBoughtThisGamepass then
	local clonedTrail = trail:Clone()
    clonedTrail.Parent = char.Head
end

At least the code looks better now

Try this, and check your Output to see what gets printed?

game.Players.PlayerAdded:Connect(function(player)
    print("Player Added")
player.CharacterAdded:Connect(function(char)
         print("Character Added")
		wait(2)
		local trail = char.Head.Trail
		local MarketPlaceService = game:GetService("MarketplaceService")
		local UserId = player.UserId
		local PlayerBoughtThisGamepass = MarketPlaceService:UserOwnsGamePassAsync(UserId, 16160354) -- Change to gamepassid
         print(PlayerBoughtThisGamepass)
		if PlayerBoughtThisGamepass then
             print("Yes!")
			trail.Enabled = true
			trail.Lifetime = 5
		else
             print("No! >:(")
			trail.Enabled = false
		end
	end)
end)

@Coolebooster this should work

game.Players.PlayerAdded:Connect(function(player)
	local char = player.Character
	
	local MarketPlaceService = game:GetService("MarketplaceService")
	local trail = game.ReplicatedStorage:FindFirstChild("Trail") --Change trail with the name of your trail
	
	if (MarketPlaceService:UserOwnsGamePassAsync(player.UserId, 16160354)) then --Change the GamePassId with your GamePassid
		local clonedTrail = trail:Clone()
		clonedTrail.Parent = char:WaitForChild("Head")
		clonedTrail.Enabled = true
		clonedTrail.Lifetime = 5
	end
	
end)

Oml, I am soo dumb. I didnt own the gamepass :man_facepalming:
My bad, thanks for helping anyways.

This is a huge bruh momentum Ah you’re fine, at least you got it fixed though that’s the important part! Also do make sure to mark your post as a solution so it’s confirmed

Won’t run if because it’s going too fast, so character will be nil.
local char = player.Character or player.CharacterAdded:Wait()

My little contribution: use pcall() as this function can crash sometimes.

local MarketPlaceService = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
	    wait(2)
	    local trail = char.Head.Trail
	    local UserId = player.UserId
	
		local Success,Has = pcall(function()
    		return MarketPlaceService:UserOwnsGamePassAsync(UserId, 16160354)
	    end)
	    if Success and Has then
		    trail.Enabled = true
		    trail.Lifetime = 5
	    else
		    trail.Enabled = false
	    end
    end)
end)
1 Like

Oh Alright thank you!

Character limit

3 Likes