local lPlayer = game.Players.LocalPlayer local char = lPlayer.Character local debounce = false function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.F then if not debounce then debounce = true local clonetrail = script.Parent.trail:Clone() char.Humanoid.WalkSpeed = 64 clonetrail.Parent = char wait(5) clonetrail:Destroy() char.Humanoid.WalkSpeed = 16 wait(8) debounce = false end end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)
You need to use the Attachment0
and Attachment1
properties of the Trail
object. Your script also errors on line 2, since the Character
needs time to load.
local plr = game:GetService("Players").LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait() function maketrail() if not char:FindFirstChildOfClass"Trail" then local trail = Instance.new"Trail" trail.Parent = char trail.Attachment0 = waitforchild(char.Head, "TrailAttachment0") trail.Attachment1 = waitforchild(char.HumanoidRootPart, "TrailAttachment1") end if not char:FindFirstChild('TrailAttachment0', true) then local attachment0 = Instance.new"Attachment" attachment0.Name = "TrailAttachment0" attachment0.Parent = char:WaitForChild"Head" end if not char:FindFirstChild('TrailAttachment1', true) then local attachment1 = Instance.new"Attachment" attachment1.Name = "TrailAttachment1" attachment1.Parent = char:WaitForChild"HumanoidRootPart" end end function waitforchild(parent, child) parent:WaitForChild(child) end game:GetService("ContextActionService"):BindAction( "MakeTrail", maketrail, false, Enum.KeyCode.F )