Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

If Player Has GamePass, He Gets A Trail, Help Please? [closed]

Asked by 5 years ago
Edited 5 years ago

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)
0
I don't think you set the gamepassID to the ID greenhamster1 180 — 5y
0
Did you even code this? (Lines 4, 48 and 49) TheeDeathCaster 2368 — 5y
0
Yes, That Doesn't Matter, But What Is Wrong With Other Parts? ItzJester2 12 — 5y
0
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. TheeDeathCaster 2368 — 5y
View all comments (7 more)
0
So, How Can I Fix That? ItzJester2 12 — 5y
0
...Remove line 25? TheeDeathCaster 2368 — 5y
0
I Removed, It Gives Me This Error: ServerScriptService.TrailGive:26: attempt to index global 'plr' (a nil value) ItzJester2 12 — 5y
0
Of course, you didn't define `plr` at all. If you'd've used Script Analysis, you'd know that. :/ Oh well. You already have the player defined as `player` in your script; why not use that? TheeDeathCaster 2368 — 5y
0
Still, It Doesn't Work Sir, Can You Write A Script Please ItzJester2 12 — 5y
0
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. TheeDeathCaster 2368 — 5y
0
I'm Trying, But I Can't Figure It Out, That's Why I Came Here so You Guys Can Help me ItzJester2 12 — 5y

Closed as Not Constructive by TheeDeathCaster

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?