Parts can't stop cloning

I wanted to add a land effect when the player lands but only when the player is not moving. I made a function that clones when it’s called and a RenderStepped to detect if the player is not moving but it keeps on cloning because the function is under the RenderStepped. Any way to prevent this?

Local script:

RS.RenderStepped:Connect(function()
	hum.StateChanged:Connect(function(old,new)
		if (new == Enum.HumanoidStateType.Landed) then
			if hum.MoveDirection.Magnitude == 0 then
				if isRunning == false then
					runAnim:Stop()
					landAnim:Play()
					landEffects()
				else
					landAnim:Stop()
				end
			else
				landAnim:Stop()
			end
		end
	end)
end)

Thank you in advance

No need to put the StateChanged on RunService, else it is making too many events and when activated, it runs all of them at the same time.

Do this:


--No more RS
hum.StateChanged:Connect(function(old,new)
	if (new == Enum.HumanoidStateType.Landed) then
		if hum.MoveDirection.Magnitude == 0 then
			if isRunning == false then
				runAnim:Stop()
				landAnim:Play()
				landEffects()
			else
				landAnim:Stop()
			end
		else
			landAnim:Stop()
		end
	end
end)
1 Like

Wow that was a quick response and a quick solution
I didn’t know I don’t need a RenderStepped to detect the MoveDirection

1 Like