So, what I am trying to do is make a "The Flash" script. So far what it does is, makes a few parts when I move but then stops making parts. I want to continuously place parts as I am moving, it just makes a few.
function showLightning(on,char) if on == true then local part = Instance.new('Part') part.Anchored = true part.CanCollide = false part.Size = Vector3.new(1,4,3) part.BrickColor = BrickColor.new('Bright yellow') part.Transparency = .6 part.CFrame = char.Torso.CFrame * CFrame.new(0,0,3) part.Parent = workspace else print'a' end end game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) char:FindFirstChild('Humanoid').Running:connect(function(speed) if speed >= 4 then showLightning(true, char) elseif speed <= 1 then showLightning(false, char) end end) end) end)
Humanoid.Running only fires when your speed changes so it's not the best way. You should make your own loop. You can simply get the speed yourself using a velocity magnitude. Try to keep the wait time low.
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) local head = char:WaitForChild('Head') while wait(1/10) do local speed = head.Velocity.Magnitude if speed >=4 then showLightning(true, char) elseif speed <= 1 then showLightning(false, char) end end end) end)