I totally misread the first snippet and somehow thought it was inside a local script, oops.
The main issue, as far as I can tell, is here:
if IKCN == "Q" then
DR:FireServer(IKCN, chr:WaitForChild("Humanoid").MoveDirection, chr:WaitForChild("HumanoidRootPart").CFrame.LookVector)
else
IS:FireServer(IKCN)
end
Here you check if the Key they press is Q, then you fire the dodge Event. Otherwise you fire InputSender.
This means pressing the Q button wont fire the InputSender at all, so it will never Fire to the server with the keyName that it provides being “Q”.
On the server you listen for the InputSender, and only if the keyName that the client sends to it is Q, which in this code will never happen as I explained, do you then connect to the DodgeRemote on the Server, which btw, would start to fire multiple times with every time you press Q, since you connect to it everytime you press Q as well if it actually worked.
This means that the InputSender will never do anything except for print “Invalid Input” whenever you press any key other that is invalid. Meanwhile the Dodge Event will be fired when pressing Q, but never listened to on the server.
I see many problems with this code, but this should be the main reason that nothing works at all.
What my recommendations are for the other issues in your code:
I would recommend simply not using the Server for the Dodge Movement, instead do it on the client since the client has full server-side control over the character anyway.
What you should be doing on the server is that whenever the player dodges, you could fire to the server, check if the player can dodge there and simply set the attributes as required (which you are doing in the dodge function already). The dodging movement can and should be handled on the client.
EDIT: I am currently not sure anymore on how to do all this exactly, but I believe you have to handle the physics of the movement on the client, so that its smooth and responsive, but also the server at the same time, so it doesnt lag for the server or other clients, otherwise the physics of the dodge would only be handled on the client. Maybe look into some posts detailing this.
This way the server knows when the player is performing a dodge through the attributes, and this information can then be used when checking for suspicious movement in an Anti-Cheat. Which would probably check for how fast the player is moving and if that was actually be plausible or not.
So if they are at some point very fast, you would check (On the Server of course) if they are dodging, and if the speed they are dodging at is what it should be. If not, there are multiple things you could do, such as set them back to their last position, kick them, or even ban them.
For more detailed explanations of anti-cheats, you should probably look to other posts, as I dont do them often.
If you still want to use this method though, maybe try doing it without the DodgeRemote and simply do the following.
if IKCN == "Unknown" then
return
else
IS:FireServer(IKCN)
end
InputSender.OnServerEvent:Connect(function(plr, keyName)
local action = ValidKeys[keyName]
if action then
print("Valid input received from: " .. plr.Name)
if plr:GetAttribute("CanDodge") and keyName == "Q" then
local character = plr.Character or plr.CharacterAdded:Wait() -- I saw you didnt do this in your dodge. This will try to get the player character and if it does not exist yet, it waits until it is added.
local Humanoid = character:WaitForChild("Humanoid")
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
Dodge(plr, Humanoid.MoveDirection, HumanoidRootPart.CFrame.LookVector)
else
print(plr.Name .. " is on dodge cooldown")
end
else
print("Invalid input received from: " .. plr.Name)
end
end)
Just in case, Im sorry if I made another mistake ;(
(I didnt look over the entire dodge function, but you said you checked it already, so I assume it works.)