Need Help With Firing Remotes In Module Script

I am currently making an Anti-Cheat that logs kicks onto a Discord Webhook. How it’s set up is you get a local script, module script, and one server script. Inside StarterCharacterScripts, you have the module script inside the local script, the local script will require() the module script then destroy its self. Preventing exploiters from disabling. The problem is that I cant fire the remote that is inside the module script to send data to the webhook. It doesn’t load in right with the WalkSpeed check function is what another person said, here is the script.

Wont be showing the Server Script, it works fine its just the remote event that is the problem

Local Script:

require(script:WaitForChild("ValidModule"))
script:Destroy()

Module Script (Will Go up to the function that i have problems with)

local KickMessage = "Exploits Detected! Contact valid4593 if this is a mistake!"

local RepStorage = game:GetService("ReplicatedStorage")
local AntiCheatEvent = RepStorage.RemoteEvents:WaitForChild("AntiCheat")

local Settings = {
	MaxWalkSpeed = 25,
    Other = true
}

local Player = game.Players.LocalPlayer
 local Character = Player.Character or Player.CharacterAdded:Wait()
  local Humanoid = Character:WaitForChild("Humanoid")
   local RunService = game:GetService("RunService")

Humanoid.Changed:Connect(function()
	if Humanoid.WalkSpeed > Settings.MaxWalkSpeed then
		AntiCheatEvent:FireServer(Humanoid.WalkSpeed)
		Player:Kick(KickMessage)
	end
end)

There are no errors

1 Like

I think the issue might be is you’re kicking the player before the players client can even fire the remote. Two alternatives would be to add a task.wait() between where you fire the server and kick the player OR you simply just kick the player via the server. So the client fires the server regarding an exploiter → server does whatever with the data (sends webhook) and kicks the player.

I just did a simple task.wait(1) in it, never knew that would be the actual issue, thanks.

No worries. One thing to note tho, the remote still might not fire if the players laggy even if you add the task.wait(1). You would have to increase the wait time by a large amount to account for latency. I honestly suggest you just kick the player via server so you don’t encounter any future issues.

E.g the players laggy → the client tries to fire the remote but takes a little bit because the player has doo doo wifi → since the client has no latency, after 1 second the player will get kicked even if the remote was still in the process of being fired → the server does not receive any information.

Above is just a “general” explanation.

Alright, I will do that, the kick will be a little harder to bypass