Does game:GetService("RunService").Stepped Causes lag?

is there something wrong with my code, because me and a friend was playing on the game and i used one move made his game crashed
heres the module script

also heres the full script

`module[“Lapse Blue”] = function(Player, Character, Value, Name,Table)
local Humanoid = Character:waitForChild(“Humanoid”)
local HumanoidRootPart = Character:waitForChild(“HumanoidRootPart”)
local Ability = Character:waitForChild(“Moveset”):waitForChild(Value…" AbilityClone")
local Cooldown = Ability:waitForChild(“Cooldown”).Value
local EndLag = Ability:waitForChild(“EndLag”).Value

if Character then
	Character:waitForChild("Values").CantDash.Value = true		
	Character:waitForChild("Values").CantRun.Value = true
	Character:waitForChild("Values").UsingMove.Value = true
	if MoveCanceled.MoveCancelSound1(Character,"Blue","Game_Animations",Value,Cooldown,EndLag) == false then return end
	Functions.Windup(0.1)
	Functions.AddVal(Character,"UsingMoveSlow",0)
	Functions.pcall(function()
		Functions.PlayAnimation2("Blue",1,.1,1,false,"Action",Character:waitForChild("Humanoid"),"Game_Animations")

	end)
	if MoveCanceled.MoveCancelSound1(Character,"Blue","Game_Animations",Value,Cooldown,EndLag) == false then return end
	Functions.Sound("GameSounds","Start",1,HumanoidRootPart,5)
	local highlight = game.ReplicatedStorage.Main.Effects.Highlighters:waitForChild("UsingMove"):Clone()
	highlight.Parent = HumanoidRootPart.Parent
	game.Debris:AddItem(highlight,2)
	local Particle = game.ReplicatedStorage.Main.Effects:waitForChild("hand"):Clone()
	Particle.Parent = Character:waitForChild("LeftFoot"):waitForChild("LeftAnkleRigAttachment")
	Particle:Emit(2)
	game.Debris:AddItem(Particle,1)
	if MoveCanceled.MoveCancelSound1(Character,"Blue","Game_Animations",Value,Cooldown,EndLag) == false then return end
	Functions.Windup(1)
	Functions.PlayAnimation2("Blue2",1,.1,1,false,"Action",Character:waitForChild("Humanoid"),"Game_Animations")
	Functions.Sound("GameSounds","Explosion11",1,HumanoidRootPart,5)
	local Rig = ReplicatedStorage.Main.Assets.Blue:Clone()


	Rig.PrimaryPart.CFrame = HumanoidRootPart.CFrame * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))--* CFrame.new(0, 1, -15)
	Rig.PrimaryPart.Anchored = true
	Rig.Parent = IgnoredInstance
	Functions.PlayAnimation2("Blue3",1,.1,1,false,"Action",Rig:waitForChild("AnimationController"),"Game_Animations")
	spawn(function()
		for i, v in pairs(Rig.RightHand.Red.Attachment:GetChildren()) do
			v.Enabled = true
		end
		wait(1.5)
		for i, v in pairs(Rig.RightHand.Red.Attachment:GetChildren()) do
			v.Enabled = false
		end
		Rig.RightHand.Red.Transparency = 0
		wait(0.5)
		Rig:Destroy()
	end)


	--[[spawn(function()
		local Properties = {
			FillTransparency = 0
		}
		Effects.Tween(0.4,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0,highlight,Properties)				
		local Properties2 = {
			FillTransparency = 1
		}
		task.wait(0.5)
		Effects.Tween(0.3,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0,highlight,Properties2)				
	end)]]

	if MoveCanceled.MoveCancelSound1(Character,"Blue","Game_Animations",Value,Cooldown,EndLag) == false then return end
	Functions.Windup(0.3)
	task.spawn(function()
		local count = 0

		repeat 
			count += 1
			task.wait(0.1)
			local Table = {
				CanDamage = true,
				dmg = 10,
				CanBlockBreak = true,	
				CanParry = false,
				CanParryBlockBreak = true,
				CanStun = true,
				StunTime = 1.5,
				knockback = 2.5,
				KnockbackType = "Look",	
				VelocityNum = 0.5,
				CanRagdoll = true,
				RagdollTime = 5,
				RagdollType = "Ragdoll2",
				SoundPlay = true,
				SoundValue = "Sound1",
				Sound = "GameSounds",
				Sound2 = "Splode",
				EffectValue = "Hp",
			}


			Functions.Sound("GameSounds","Splode",1,HumanoidRootPart,5)
			coroutine.resume(coroutine.create(function()
				if MoveCanceled.MoveCancelSound1(Character,"Blue","Game_Animations",Value,Cooldown,EndLag) == false then return end

				for _ = 1, 25 do
					wait()
					Functions.Hitbox(Character,Name,Table,Rig.RightHand.Red.CFrame,50,50, 50, 50)
					if Character:FindFirstChild("StopCore") then
						break
					else 
						return
					end
				end
			end))

			ClientFx.CamShake(Character,"BigBump")
		until count == 15
	end)		
	--Functions.Sound("GameSounds","AirComboWoosh1",1,HumanoidRootPart,5)
	--Functions.Sound("GameSounds","AirRocks",1,HumanoidRootPart,5)

	--ClientFx.CamShake(Character,"Custom",0.5,3,15,0.3,0.3)
	--ClientFx.CamShake(Character,"Custom",0.5,5,1,0.5,0.7)




	Functions.pcall(function()
		if Character:FindFirstChild("Attacked")  or Character:FindFirstChild("Stunned")  or Character:FindFirstChild("BlockBreak") or Character:FindFirstChild("TimeStopped") or Character:FindFirstChild("Ragdolled") or Character:FindFirstChild("Disabled") or Character:FindFirstChild("StandDisabled") or Character:FindFirstChild("Parryed") or Character:FindFirstChild("Cancelled") or Character:FindFirstChild("TrueCancelled")  then
			local Humanoid = Character:waitForChild("Humanoid")
			local HumanoidRootPart = Character:waitForChild("HumanoidRootPart")
			Functions.Sound1(HumanoidRootPart,"GameSounds","MoveCancel",math.random(85,100)/100)
			Humanoid.WalkSpeed = 13
			Humanoid.JumpPower = 50
			Functions.StopAnimation("StartAir",Humanoid,"Game_Animations")
			Functions.Cooldown(Value,Cooldown,Character)
			ReplicatedStorage:waitForChild("Main").GameRemotes.Stand:FireClient(Player, Character, Value, Name,Table)(Value)
			task.wait(EndLag)	
			Character.Values.UsingMove.Value = false
			Character.Values.CantDash.Value = false		
			Character.Values.CantRun.Value = false	
			Functions.Destroy(Character,"UsingMoveSlow")
			print("edd")
			return	
		end
		Functions.Windup(0.2)
		Functions.Destroy(Character,"UsingMoveSlow")
		Remote:FireClient(Player, Character, Value, Name,Table)
		task.wait(EndLag)	
		Character:waitForChild("Values").UsingMove.Value = false
		Character:waitForChild("Values").CantDash.Value = false		
		Character:waitForChild("Values").CantRun.Value = false
	end)
else
	Remote:FireClient(Player, Character, Value, Name,Table)
end 

end`

Greetings! It seems your issue is due to the fact you are using wait(), whereas with .Stepped:, it uses Wait().

Using RunService.Stepped:Wait() should fix your issue.

wait() does not exist with the .Stepped event, but in order to avoid excessive lag by erroring indefinitely, it will timeout.

1 Like