Player being kicked?

Hello, I have a block button for my combat system, and when it plays it fires a remote to the server and the server makes a bool value inside the player = to true to indicate that the player is blocking. Since hackers can infinitely block, I made it so when blocking you can’t jump and you’re very slow, and if you can jump/are faster then set speed, you get kicked. I can’t figure out why the player is kicked after unblocking?

client

UserInputService.InputBegan:Connect(function(KeyInput,gameProccessed)
	if gameProccessed then return end
	if KeyInput.KeyCode == Enum.KeyCode.F and BlockDebounce and Stunned.Value == false then
		BlockDebounce = false
		local WalkSpeed = character.Humanoid.WalkSpeed
		local JumpPower = character.Humanoid.JumpPower
		game.ReplicatedStorage.Remotes.BlockRemote:FireServer(true,Blocking)
        ---Blocking is just a bool value inside the character to check if the player is blocking or not
		BlockAnimation:Play()
		wait(.30)
		BlockAnimation:AdjustSpeed(0)
		while UserInputService:IsKeyDown(Enum.KeyCode.F) do wait() end
		game.ReplicatedStorage.Remotes.BlockRemote:FireServer(false,Blocking,WalkSpeed,JumpPower)
		BlockAnimation:AdjustSpeed(1)
		wait(3)
		BlockDebounce = true
	end
end)

server

game.ReplicatedStorage.Remotes.BlockRemote.OnServerEvent:Connect(function(player,value,blocking,speed,jump)
	local char = player.Character or player.Character.CharacterAdded:Wait()
	if value == true then
		char.Humanoid.WalkSpeed = 7
		char.Humanoid.JumpPower = 0
	else
		char.Humanoid.WalkSpeed = speed
		char.Humanoid.JumpPower = jump
	end
	blocking.Value = value
	print(blocking.Value)
	wait(1)
	char.Humanoid.Changed:Connect(function()
		if blocking.Value == true then
			if char.Humanoid.WalkSpeed ~= 7 or char.Humanoid.JumpPower ~= 0 then
                --even when blocking is = to false this still runs?
				player:Kick("Nice Exploits")
				return
			end
		end
	end)
end)

The kick happens because you never disconnect the Changed event, so it fires again when this line runs:

char.Humanoid.WalkSpeed = speed

since you change the blocking.Value back after setting the speed, the event handler still sees the value as true and does the kick.

Another thing is, if an exploiter changed their WalkSpeed, the server wouldn’t be able to see it, same for JumpPower, rendering this check kinda pointless:

if char.Humanoid.WalkSpeed ~= 7 or char.Humanoid.JumpPower ~= 0 then
1 Like