Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
while Humanoid.MoveDirection ~= Vector3.new(0,0,0) do
wait()
local Clouds = {}
local ClonedCloud = Cloud:Clone()
table.insert(Clouds, #Clouds + 1, ClonedCloud)
for index, ClonedCloud in ipairs(Clouds) do
ClonedCloud.Position = HRP.Position+Vector3.new(math.random(-1,1),-3,0)
ClonedCloud.Parent = workspace.debris
local BV = Instance.new("BodyVelocity")
BV.Parent = ClonedCloud
ClonedCloud.BodyVelocity.Velocity = CFrame.lookAt(ClonedCloud.Position,HRP.Position).LookVector*5
game.Debris:AddItem(ClonedCloud,0.5)
end
end
end)
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local running = false
local function repeattingfunction()
while running do
local Clouds = {}
local ClonedCloud = Cloud:Clone()
table.insert(Clouds, #Clouds + 1, ClonedCloud)
for index, ClonedCloud in ipairs(Clouds) do
ClonedCloud.Position = HRP.Position+Vector3.new(math.random(-1,1),-3,0)
ClonedCloud.Parent = workspace.debris
local BV = Instance.new("BodyVelocity")
BV.Parent = ClonedCloud
ClonedCloud.BodyVelocity.Velocity = CFrame.lookAt(ClonedCloud.Position,HRP.Position).LookVector*5
game.Debris:AddItem(ClonedCloud,0.5)
wait(.2)
end
end
end
humanoid.Running:Connect(function(speed)
if speed >0 then
running=true
repeattingfunction()
else
running=false
end
end)
I think I need to adjust it a bit still, but seems to works fine and the only thing I had to change was the bodyvelocity to this ClonedCloud.BodyVelocity.Velocity = HRP.CFrame.LookVector*-3