I need it to be activated when I reach a certain speed, and deactivate if I reach a speed lower than the activation speed. I've tried putting it in while loops, repeats and if statements etc. The code I have so far is below.
local sp = script.Parent.Parent.Character:FindFirstChild("Humanoid") activate = 50 deactivate = 49 function trail() wait(0.01) local ft = Instance.new("Part") ft.TopSurface = "Smooth" ft.BottomSurface = "Smooth" ft.Anchored = true ft.FormFactor = "Custom" ft.Size = Vector3.new(0.98, 1.98, 0.98) ft.Transparency = 0.7 ft.Parent = game.workspace ft.CanCollide = false ft.BrickColor = BrickColor.new("Bright yellow") ft.CFrame = CFrame.new(script.Parent.Parent.Character:FindFirstChild("Torso").Position.X,script.Parent.Parent.Character:FindFirstChild("Torso").Position.Y-0,script.Parent.Parent.Character:FindFirstChild("Torso").Position.Z)--Edited game.Debris:AddItem(ft,0.8) local fla = Instance.new("Part") fla.TopSurface = "Smooth" fla.BottomSurface = "Smooth" fla.Anchored = true fla.FormFactor = "Custom" fla.Size = Vector3.new(0.98, 1.98, 0.98) fla.Transparency = 0.7 fla.Parent = game.workspace fla.CanCollide = false fla.BrickColor = BrickColor.new("Bright yellow") fla.CFrame = CFrame.new(script.Parent.Parent.Character:FindFirstChild("Left Arm").Position.X,script.Parent.Parent.Character:FindFirstChild("Left Arm").Position.Y-0,script.Parent.Parent.Character:FindFirstChild("Left Arm").Position.Z)--Edited game.Debris:AddItem(fla,0.8) local fra = Instance.new("Part") fra.TopSurface = "Smooth" fra.BottomSurface = "Smooth" fra.Anchored = true fra.FormFactor = "Custom" fra.Size = Vector3.new(0.98, 1.98, 0.98) fra.Transparency = 0.7 fra.Parent = game.workspace fra.CanCollide = false fra.BrickColor = BrickColor.new("Bright yellow") fra.CFrame = CFrame.new(script.Parent.Parent.Character:FindFirstChild("Right Arm").Position.X,script.Parent.Parent.Character:FindFirstChild("Right Arm").Position.Y-0,script.Parent.Parent.Character:FindFirstChild("Right Arm").Position.Z)--Edited game.Debris:AddItem(fra,0.8) local fll = Instance.new("Part") fll.TopSurface = "Smooth" fll.BottomSurface = "Smooth" fll.Anchored = true fll.FormFactor = "Custom" fll.Size = Vector3.new(0.98, 1.98, 0.98) fll.Transparency = 0.7 fll.Parent = game.workspace fll.CanCollide = false fll.BrickColor = BrickColor.new("Bright yellow") fll.CFrame = CFrame.new(script.Parent.Parent.Character:FindFirstChild("Left Leg").Position.X,script.Parent.Parent.Character:FindFirstChild("Left Leg").Position.Y-0,script.Parent.Parent.Character:FindFirstChild("Left Leg").Position.Z)--Edited game.Debris:AddItem(fll,0.8) local frl = Instance.new("Part") frl.TopSurface = "Smooth" frl.BottomSurface = "Smooth" frl.Anchored = true frl.FormFactor = "Custom" frl.Size = Vector3.new(0.98, 1.98, 0.98) frl.Transparency = 0.7 frl.Parent = game.workspace frl.CanCollide = false frl.BrickColor = BrickColor.new("Bright yellow") frl.CFrame = CFrame.new(script.Parent.Parent.Character:FindFirstChild("Right Leg").Position.X,script.Parent.Parent.Character:FindFirstChild("Right Leg").Position.Y-0,script.Parent.Parent.Character:FindFirstChild("Right Leg").Position.Z)--Edited game.Debris:AddItem(frl,0.8) local fh = Instance.new("Part") fh.TopSurface = "Smooth" fh.BottomSurface = "Smooth" fh.Anchored = true fh.FormFactor = "Custom" fh.Size = Vector3.new(0.98, 0.98, 0.98) fh.Transparency = 0.7 fh.Parent = game.workspace fh.CanCollide = false fh.BrickColor = BrickColor.new("Bright yellow") fh.CFrame = CFrame.new(script.Parent.Parent.Character:FindFirstChild("Head").Position.X,script.Parent.Parent.Character:FindFirstChild("Head").Position.Y-0,script.Parent.Parent.Character:FindFirstChild("Head").Position.Z)--Edited game.Debris:AddItem(fh,0.8) end while sp.WalkSpeed <= activate do trail() end
Thanks!