Hello developers! In this my first tutorial I will show you how to make a trail, I will show you some different methods (no gamepass, with gamepass, admins only, on sword).
- Insert a Trail in ServerStorage
- Customize it as you want (change color, change lenght, etc.)
- Insert a Script in ServerScriptService
Now what you need to decide is if make a Trail that require a gamepass or a Trail that doesen’t require any gamepass.
No gamepass
Open the Script we’ve made before and write this into it:
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local Trail = game.ServerStorage.Trail:Clone() --here we create the variable of the Trail we've made at the beginning
Trail.Parent = char.Head --here we set the Parent of the Trails as the Head of the player's character
local attachment0 = Instance.new("Attachment") --here we create an attachment that is needed to connect the Trail to the Head of the player
attachment0.Parent = char.Head --here we set the parent of the attachment as the player's head
attachment0.Name = "Attachment0" --here we change the name of the attachment
local attachment1 = Instance.new("Attachment") --here we create another attachment
attachment1.Parent = char.HumanoidRootPart --here we set the parent of the attachment as the player's HumanoidRootPart
attachment1.Name = "Attachment1" --here we change the name of the attachment
Trail.Attachment0 = attachment0 --here we set the trail's attachment0 as the attachment0 we've made before
Trail.Attachment1 = attachment1 --here we set the trail's attachment1 as the attachment1 we've made before
end)
end)
With gamepass
local MarketplaceService = game:GetService("MarketplaceService")
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
if (MarketplaceService:UserOwnsGamePassAsync(player.UserId, 0)) then --change 0 with the ID of your gamepass
local Trail = game.ServerStorage.Trail:Clone() --here we create the variable of the Trail we've made at the beginning
Trail.Parent = char.Head --here we set the Parent of the Trails as the Head of the player's character
local attachment0 = Instance.new("Attachment") --here we create an attachment that is needed to connect the Trail to the Head of the player
attachment0.Parent = char.Head --here we set the parent of the attachment as the player's head
attachment0.Name = "Attachment0" --here we change the name of the attachment
local attachment1 = Instance.new("Attachment") --here we create another attachment
attachment1.Parent = char.HumanoidRootPart --here we set the parent of the attachment as the player's HumanoidRootPart
attachment1.Name = "Attachment1" --here we change the name of the attachment
Trail.Attachment0 = attachment0 --here we set the trail's attachment0 as the attachment0 we've made before
Trail.Attachment1 = attachment1 --here we set the trail's attachment1 as the attachment1 we've made before
end
end)
end)
Do you want to add a Trail to your sword? Nothing simpler!
Add a Trail to a sword
-
Get a sword model and add the two red parts in the images and set the CanCollide to false
-
Group the parts and add a WeldCostraint into them, Set the Part0 as the parent part and the Part1 as the handle:
-
Insert a Trail in the UpperPart, customize it as you want and add an Attachment for each of the red parts:
-
Set the Attachment0 of the trail as the UpperAttachment and the LowerAttachment as the Attachment1:
Now everything is ready. You can set the transparency of the red parts to 1.
And now we have a sword with a rainbow trail:
Wait what? Do you want a trail for admins only? Nothing simpler!
Trail for admins only
Insert a Script in ServerScriptService and write this:
local admins = { --here we create a table with the IDs of the admins
1631420942 --Change this ID with yours, you can add another one by inserting a comma after it, going to the head and inserting another one
}
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
if table.find(admins, player.UserId) then --here we check if the player that join is an admin searching in the table we've made before
local trail = game.ServerStorage.Trail:Clone() --here we create the variable of the Trail we've made at the beginning
trail.Parent = char.Head --here we set the Parent of the Trails as the Head of the player's character
local attachment0 = Instance.new("Attachment") --here we create an attachment that is needed to connect the Trail to the Head of the player
attachment0.Parent = char.Head --here we set the parent of the attachment as the player's head
attachment0.Name = "Attachment0" --here we change the name of the attachment
local attachment1 = Instance.new("Attachment") --here we create another attachment
attachment1.Parent = char.HumanoidRootPart --here we set the parent of the attachment as the player's HumanoidRootPart
attachment1.Name = "Attachment1" --here we change the name of the attachment
trail.Attachment0 = attachment0 --here we set the trail's attachment0 as the attachment0 we've made before
trail.Attachment1 = attachment1 --here we set the trail's attachment1 as the attachment1 we've made before
end
end)
end)
This is all for this tutorial, I hope this has helped you!