Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My Trail Gamepass for my game isn't working?

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)

3 comments

0

are you sure this is a serverscript in serverscriptservice.. because you're defining character as script.Parent.Parent.Parent

0

I don't really know much about scripting, if so what will I have to do to make sure its a server script?

0

A server script looks like a white scroll. A local script looks like a scroll with a blue person on it.

1 answer

✓ Accepted answer

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.

1 comment

0

Thank you sir!

This discussion is preserved as it was. New answers, comments, and votes are closed.