How to check if a player holds the Windows exit button

Hi, I am currently working on the movement system for my game. I’m doing this with a combination of impulses and linear forces. The movement system works perfectly, however, when a player holds the windows exit button (The X button), the local scripts seem to continue running, but they take the players data from when they began to hold X. This means systems I have in place like a slow deceleration or roll, continue doing their logic and never end until the x has stopped being pressed.

I was wondering if there would be a way to check for this
(Glitch shown bellow)
https://gyazo.com/274b3bdc3cb3fe9b5e999ad7b3e3271c

Any advice greatly appreciated : )

1 Like

I think it’s because of the paused frames and the movement systems are taking that as low fps, thus speeding up the player for fair gameplay. How about first detecting if their fps is <= 0.1, then if it is, pause the movement system? Something like very low fps like this may get exploited sometimes by people that uses the tab key, similar to Slap Battles (However, I think this one is a bit more different).

Does your movement system run on RenderStepped? If so, does it have the delta input taken? (game:GetService("RunService").RenderStepped:Connect(function(delta) end)). If it does, then you can very well measure the player’s frame rate. If the delta spiked over a certain threshold, then you can pause the movement system.

Try something like:

local threshold = 0.5 --try adjusting this
local prevDelta = 0
game:GetService("RunService").RenderStepped:Connect(function(delta)
	if (delta - prevDelta) < threshold then
		--continue
	else
		--pause
	end
	prevDelta = delta --this should be at the very end
end)

Yeah it does, I’ll check for spikes in delta then, thanks :slight_smile:

If it works I’ll check it as an answer, currently out right now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.