Help with Premium Benefits

Hi, I am trying to make a script that gives players a trail if they have premium but if the player does not have premium the trail color will change to white. The trail works for the premium player but the trail doesn’t even show for the non-premium player. I checked the output and script analysis and it did not drop anything.

I used A Guide to Providing Benefits to Roblox Premium Members for your Game to help me make this.

The script is in the ServerScriptService. The trail is in the ServerStorage

local ReplicatedStorage = game.ServerStorage


local players = game.Players
players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(char)
		if player.MembershipType == Enum.MembershipType.Premium then
			local Trail = game.ServerStorage.Trail:Clone()
						
			
			Trail.Parent = char.Head
			
			local attachment0 = Instance.new("Attachment", char.Head)
			attachment0.Name = "attachment0"
			
			local attachment1 = Instance.new("Attachment", char.HumanoidRootPart)
			attachment1.Name = "attachment1"
			
			Trail.Attachment0 = attachment0
			Trail.Attachment1 = attachment1
			if player.MembershipType ~= Enum.MembershipType.Premium then
				Trail.Color = Color3.new(1,1,1)
			end
		end
	end)
end)

you check if they have premium before you clone the trail so if they don’t have premium it won’t clone

also trail.Color needs a ColorSequence not Color3

I tried to do this, but it did not work.

local ReplicatedStorage = game.ServerStorage
local white = Color3.new(1,1,1)
local Trail = ReplicatedService.Trail:Clone()

local players = game.Players
players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(char)
		if player.MembershipType == Enum.MembershipType.Premium then
			
			
			Trail.Parent = char.Head
			
			local attachment0 = Instance.new("Attachment", char.Head)
			attachment0.Name = "attachment0"
			
			local attachment1 = Instance.new("Attachment", char.HumanoidRootPart)
			attachment1.Name = "attachment1"
			
			Trail.Attachment0 = attachment0
			Trail.Attachment1 = attachment1
			if player.MembershipType ~= Enum.MembershipType.Premium then
				Trail.Color = ColorSequence.new{
					ColorSequenceKeypoint.new(0, white)
				}
			end
		end
	end)
end)

Why. Why would you do that.


if player.MembershipType ~= Enum.MembershipType.Premium then

this line here will never return true, because for it to run, the player has to have premium already.


local Trail = ReplicatedService.Trail:Clone()

This should be inside CharacterAppearanceLoaded function. It current only fires once


I’ll try rewriting your code so that it should work, or at least be closer to working

local ServerStorage = game.ServerStorage
local players = game.Players
players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(char)
        local Trail = ServerStorage.Trail:Clone()
		Trail.Parent = char.Head
			
		local attachment0 = Instance.new("Attachment", char.Head)
		attachment0.Name = "attachment0"
			
		local attachment1 = Instance.new("Attachment", char.HumanoidRootPart)
		attachment1.Name = "attachment1"
		
		Trail.Attachment0 = attachment0
		Trail.Attachment1 = attachment1
		if player.MembershipType ~= Enum.MembershipType.Premium then
			Trail.Color = ColorSequence.new{
				ColorSequenceKeypoint.new(Color3.new(1,1,1)) --This is valid. I checked the docs
			}
		end
	end)
end)

you have to remove this line, it checks if the player has premium before it clones the trail, as i said before

The trail is given to the non-premium player but it does not change its color
It drops an error in the output: ServerScriptService.Script:18: invalid argument #1 to ‘new’ (number expected, got Color3) - Server - Script:18
on this line: ColorSequenceKeypoint.new(Color3.new(1,1,1))

Oh I know why
replace

Trail.Color = ColorSequence.new{
				ColorSequenceKeypoint.new(Color3.new(1,1,1)) --This is valid. I checked the docs
			}

with

Trail.Color = ColorSequence.new(Color3.new(1,1,1))
Trail.Color = ColorSequence.new{
				ColorSequenceKeypoint.new(0,Color3.new(1,1,1)),
ColorSequenceKeypoint.new(1,Color3.new(1,1,1)) 
			}

is the same as

Trail.Color = ColorSequence.new(Color3.new(1,1,1))

Heyo. Thanks for checking out my tutorial.

I see what you’re doing wrong.

So first off, the trail must be paranted to the HumanoidRootPart, not the head.

And you’ll need to check and see if the player already has all the necessary attachments before attaching the trail.

Here’s a script I’ve written for you that I’ve tested and should work.

local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")

local white = Color3.new(1,1,1)


local function CheckAttachments(character) -- Check to see if the player's character has the necessary attachments
	if not character.Head:FindFirstChild("FaceFrontAttachment") then
        local Attachment = Instance.new("Attachment")
        Attachment.Name = "FaceFrontAttachment"
        Attachment.Position = Vector3.new(0, 0, -0.6)
		Attachment.Parent = character.Head
    end
	if character:FindFirstChild("UpperTorso") then
		if not character.UpperTorso:FindFirstChild("WaistRigAttachment") then
            local Attachment = Instance.new("Attachment")
            Attachment.Name = "WaistRigAttachment"
            Attachment.Position = Vector3.new(-0.8, 0, 0)
			Attachment.Parent = character.UpperTorso
        end
    else
		if not character.Torso:FindFirstChild("WaistRigAttachment") then
            local Attachment = Instance.new("Attachment")
            Attachment.Name = "WaistRigAttachment"
            Attachment.Position = Vector3.new(0, -0.75, 0)
			Attachment.Parent = character.Torso
        end
    end
end

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)

           local trail = ServerStorage.Trail:Clone()
           trail.Parent = character.HumanoidRootPart
           CheckAttachments(character)
           if character:FindFirstChild("UpperTorso") then
               trail.Attachment0 = character.Head.FaceFrontAttachment
               trail.Attachment1 = character.UpperTorso.WaistRigAttachment
           else
               trail.Attachment0 = character.Head.FaceFrontAttachment
               trail.Attachment1 = character.Torso.WaistBackAttachment
		   end
		   if player.MembershipType == Enum.MembershipType.Premium then
               trail.Color = ColorSequence.new(white)
           end
			
    end)
end)

Hi. This worked but I just changed it abit

I replaced CharacterAdded with CharacterAppearanceLoaded

and I’m not sure why it worked like this but I Changed it to

if player.MembershipType == Enum.MembershipType.None then
trail.Color = ColorSequence.new(white)

Final code

local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")

local white = Color3.new(1,1,1)


local function CheckAttachments(character) -- Check to see if the player's character has the necessary attachments
	if not character.Head:FindFirstChild("FaceFrontAttachment") then
		local Attachment = Instance.new("Attachment")
		Attachment.Name = "FaceFrontAttachment"
		Attachment.Position = Vector3.new(0, 0, -0.6)
		Attachment.Parent = character.Head
	end
	if character:FindFirstChild("UpperTorso") then
		if not character.UpperTorso:FindFirstChild("WaistRigAttachment") then
			local Attachment = Instance.new("Attachment")
			Attachment.Name = "WaistRigAttachment"
			Attachment.Position = Vector3.new(-0.8, 0, 0)
			Attachment.Parent = character.UpperTorso
		end
	else
		if not character.Torso:FindFirstChild("WaistRigAttachment") then
			local Attachment = Instance.new("Attachment")
			Attachment.Name = "WaistRigAttachment"
			Attachment.Position = Vector3.new(0, -0.75, 0)
			Attachment.Parent = character.Torso
		end
	end
end

Players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(character)

		local trail = ServerStorage.Trail:Clone()
		trail.Parent = character.HumanoidRootPart
		CheckAttachments(character)
		if character:FindFirstChild("UpperTorso") then
			trail.Attachment0 = character.Head.FaceFrontAttachment
			trail.Attachment1 = character.UpperTorso.WaistRigAttachment
		else
			trail.Attachment0 = character.Head.FaceFrontAttachment
			trail.Attachment1 = character.Torso.WaistBackAttachment
		end
		if player.MembershipType == Enum.MembershipType.None then
			trail.Color = ColorSequence.new(white)
		end
	end)
	end)

I don’t understand why you changed it to CharacterAppearanceLoaded, but I’m glad I could help.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.