Hello
I am trying to make a sprinting system, it works but I wanted to add a trail that the player leaves behind when they sprint, to indicate they they are sprinting.
I tried to do this but whenever I try it I always have this error in the Output:
SpeedTrail is not a valid member of ServerStorage "ServerStorage"
Here is the script I made:
local ContextActionService = game:GetService("ContextActionService")
local TweenService = game:GetService("TweenService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Camera = game.Workspace.CurrentCamera
local Trail = game.ServerStorage.SpeedTrail:Clone()
local attachment0 = Instance.new("Attachment")
attachment0.Position = Vector3.new(0, 0.8, 0)
attachment0.Parent = Character.Torso
local attachment1 = Instance.new("Attachment")
attachment1.Position = Vector3.new(0, -1, 0)
attachment1.Parent = Character.Torso
Trail.Attachment0 = attachment0
Trail.Attachment1 = attachment1
local Sprinting = false
local function Sprint(ActionName, InputState)
if InputState == Enum.UserInputState.Begin then
Sprinting = true
Humanoid.WalkSpeed = 16*2
TweenService:Create(Camera, TweenInfo.new(1), {FieldOfView = 80}):Play()
Trail.Enabled = true
else
Sprinting = false
Humanoid.WalkSpeed = 16
TweenService:Create(Camera, TweenInfo.new(2), {FieldOfView = 70}):Play()
Trail.Enabled = false
end
end
ContextActionService:BindAction("Sprint", Sprint, true, Enum.KeyCode.LeftShift, Enum.KeyCode.ButtonL2)
ContextActionService:SetImage("Sprint", "rbxassetid://1921587812")
ContextActionService:SetDescription("Sprint", "Run")
ContextActionService:SetPosition("Sprint", UDim2.new(.75, -50, 0, 1))
ContextActionService:GetButton("Sprint").Size = UDim2.new(.25, 0, .25, 0)
How can I do this?