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)
COMMUNITY QUESTION
How do I make the trail work in a live server?
1 answer
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
)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
https://gyazo.com/b4ebd27be3c4d24061e2713237fdf80e
Are you using a server-side script (Script) or a client-side script (LocalScript)? If the former, you'll want to make sure you're using a LocalScript. Also make sure the script is not in a public place like Workspace or ServerScriptService.