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)
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)
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)
@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
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)
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
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)