Any way to prevent .Touched from lagging?

Am I doing something wrong?

Here’s the code :

The hitbox is quite big, it was around (50,50,130) in this gif :

https://i.gyazo.com/ff177496aa94924d26b457b9cf52142c.gif

1 Like

There is no debounce; the function connected to the hit event will fire quite a few times likely.

(and :Remove() is deprecated, use :Destroy(), same for Connect/Disconnect instead of using connect/disconnect)

2 Likes

Which function and which event? the only event there is the .Touched, and it has no function connected to it.

The DamageCheck function inside the for i,v that is inside the repeat statement has a wait() debounce

Isn’t there like a whitelist/blacklist for .Touched?

Yes it does, it is an anonymous function but it still is a connected function.

That is not what a debounce is

local db = false
.Touched:connect(function()
if db then return end
db = true
-- stuff
db = false
end)

ah, there’s a debounce inside the DamageCheck function then

Back to the .Touched :

Would disconnecting and reconnecting the event as a debounce work?

Theoretically it would but in practice that is very inefficient, might as well just check a bool.

Mind you a debounce inside that loop is not gonna help at all, you need to put a debounce right after the function is called.

Its good practice to attach your code as text rather than a picture. So instead of this

bleep bloop a picture

You’d do this.

bleep bloop my code
Anims["ShiftGameTabsUp"] = function(Frames, Table)
	
	Sequence.New("ShiftGameTabsUp", .15, Enum.SequenceType.Conditional, function()
		return Table.TabsUp
	end)
	
	for i = 1, #Frames do
		local Frame = Frames[i]
		
		local DefaultPosition = UDim2.new(Frame.Position.X.Scale, Frame.Position.X.Offset, 0.5, -Frame.Size.Y.Offset / 2)
		
		Sequence.NewAnim("ShiftGameTabsUp",
			Enum.AnimationType.TwoPoint, 
			Enum.AnimationControlPointState.Static,
			0,
			Frame,
			"Position",
			{
				DefaultPosition;
				DefaultPosition + UDim2.new(0, 0, 0, -200) 
			},
			"outBack", 
			.15
		)
	end
	
	Sequence.PreRender("ShiftGameTabsUp")
--	Sequence.Start("ShiftGameTabsUp")
end

To do the special formatting you type this:

derp

18

2 Likes

I’ll try do it next time, thanks.