If The Player Has Bought The Game Pass, He Has A Trail, I'm Trying to figure out how to do it but it's not working, what am i doing wrong?
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamePassID = ????
function onPlayerSpawned(player)
local hasPass = false
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID)
print("Has Game Pass for Gun")
end)
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass == true then
local Trail = game.ServerStorage["Trail"]
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local plrTrail = Trail:Clone()
plrTrail.Parent = char.HumanoidRootPart
if char:FindFirstChild("UpperTorso") then
plrTrail.Attachment0 = char.Head.FaceFrontAttachment
plrTrail.Attachment1 = char.Torso.RootRigAttachment
else
plrTrail.Attachment0 = char.Head.FaceFrontAttachment
plrTrail.Attachment1 = char.Torso.WaistBackAttachment
end
end)
local character = script.Parent.Parent.Parent
end)
end
end
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function()
onPlayerSpawned(player)
end)
end)
Players.PlayerSpawned:Connect(onPlayerSpawned)

11 comments
I don't think you set the gamepassID to the ID
Did you even code this? (Lines 4, 48 and 49)
Yes, That Doesn't Matter, But What Is Wrong With Other Parts?
If you really did code this, you'd know that that's because of line 25; it waits for when a player joins the game, in other words, it wont add the trail until another player joins.
So, How Can I Fix That?
...Remove line 25?
I Removed, It Gives Me This Error: ServerScriptService.TrailGive:26: attempt to index global 'plr' (a nil value)
Of course, you didn't define
plrat all. If you'd've used Script Analysis, you'd know that. :/ Oh well. You already have the player defined asplayerin your script; why not use that?Still, It Doesn't Work Sir, Can You Write A Script Please
No, I will not. It's quite evident you didn't write this script. :/ Please come back when you've at least tried to make an attempt.
I'm Trying, But I Can't Figure It Out, That's Why I Came Here so You Guys Can Help me