Ad
Log in to vote
0

My Trail Gamepass for my game isn't working?

Asked by 10 days ago

I got a trail game pass script that, is not working? Could someone tell me whats wrong?

--Put in a script in ServerScriptService 
local passId = 4916610
local MPS = game:GetService("MarketplaceService")

local function isAuthenticated(userId, gamePassId) -- define outside the PlayerAdded event
    return MPS:UserOwnsGamePassAsync(userId, gamePassId)
end

game:GetService("Players").PlayerAdded:Connect(function(plr) -- :connect is deprecated, use :Connect

    plr.CharacterAdded:Connect(function(char) -- wait for the character! 
        if isAuthenticated(plr.UserId, passId) then
          local Trail = game.ServerStorage["Red 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)
end)

0
are you sure this is a serverscript in serverscriptservice.. because you're defining character as script.Parent.Parent.Parent SulaymanArafat 195 — 10d
0
I don't really know much about scripting, if so what will I have to do to make sure its a server script? TimeExotic -6 — 10d
0
A server script looks like a white scroll. A local script looks like a scroll with a blue person on it. abnotaddable 862 — 10d

1 answer

Log in to vote
0
Answered by 10 days ago
Edited 10 days ago

Before I answer this, please indent properly! Make sure this is a server script in ServerScriptService

local passId = 4916610
local MPS = game:GetService("MarketplaceService")

local function isAuthenticated(userId, gamePassId)
    return MPS:UserOwnsGamePassAsync(userId, gamePassId)
end

local function CheckAttachments(char)
    if not char.Head:FindFirstChild("FaceFrontAttachment") then
        local Attachment = Instance.new("Attachment")
        Attachment.Name = "FaceFrontAttachment"
        Attachment.Position = Vector3.new(0,0,-0.6)
        Attachment.Parent = char.Head
    end
    if char:FindFirstChild("UpperTorso") then
        if not char.UpperTorso:FindFirstChild("WaistRigAttachment") then
            local Attachment = Instance.new("Attachment")
            Attachment.Name = "WaistRigAttachment"
            Attachment.Position = Vector3.new(-0.8 ,0,0)
            Attachment.Parent = char.UpperTorso
        end
    else
        if not char.Torso:FindFirstChild("WaistRigAttachment") then
            local Attachment = Instance.new("Attachment")
            Attachment.Name = "WaistRigAttachment"
            Attachment.Position = Vector3.new(0,-0.75,0)
            Attachment.Parent = char.Torso
        end
    end
end

game:GetService("Players").PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        if isAuthenticated(plr.UserId, passId) then
            local plrTrail = game.ServerStorage["Red Trail"]:Clone()
            plrTrail.Parent = char.HumanoidRootPart
            CheckAttachments(char)
            if char:FindFirstChild("UpperTorso") then
                plrTrail.Attachment0 = char.Head.FaceFrontAttachment
                plrTrail.Attachment1 = char.UpperTorso.WaistRigAttachment
            else
                plrTrail.Attachment0 = char.Head.FaceFrontAttachment
                plrTrail.Attachment1 = char.Torso.WaistBackAttachment
            end
        end
    end)
end)

I added the CheckAttachments function to make sure the attachments are actually there.

0
Thank you sir! TimeExotic -6 — 10d
Ad

Answer this question