A game similar to BM:Unleashed with keystrokes like this:
I’m just not really sure where to start with this. I’m really not good with anything related to timing in scripts. Any help is appreciated!
A game similar to BM:Unleashed with keystrokes like this:
I’m just not really sure where to start with this. I’m really not good with anything related to timing in scripts. Any help is appreciated!
You could listen to players keystrokes inside a local script and put them inside a string then send the string to the server using a remote event, when the server recieves the string exectue code based on whats inside the string. for example if its “DDC” then do this. Best way to start would be to just do it using if statements and later refine it to be more compact and optimized.
Security Risks
Sending the entire string to the server has a big risk of letting exploiters just send entire sequences of keystrokes without actually pressing them. A fix for that would be to send each stroke separately but it would require more remote calls and so it would use more bandwith. im not really good at code security so dont take it for granted
As @Artex_112 said, listen to keystrokes in a localscript. Concatenate the keys into a string by adding onto it every time a keystroke is recorded within a specific timeframe. If the time between keystrokes exceeds the duration you set then fire a remote event with the string and handle the skill with a script. Regarding security concerns, should your game be successful enough to be targeted by exploiters, simply encrypt the string in the localscript with a randomised key and decrypt it in the script.
One thing you could do is make an invisible textbox, make the player focus on to that textbox by using textbox:CaptureFocus()
and as the player types a keystroke you can use a table to see if the keystrokes match anther keystroke and execute a command. If the player stops typing for more than 2 seconds then you cancel the process and remove the textbox.
Does that allow the player to move while typing, too?
Nope. It would stop all movement.
Thank you all for the help! I’ll mark Artex’s post as the solution since I’m also going to convert my current code to his recommendations. I ended up with code looking something like this:
local replicated_storage = game:GetService("ReplicatedStorage")
local utils = require(replicated_storage:WaitForChild("utils"))
local _, _, uis = utils:services()
local combos = {
{
[1] = Enum.KeyCode.A,
[2] = Enum.KeyCode.A,
[3] = Enum.KeyCode.Q
}
}
local combo = {}
local index = 0
local remove
local removal_time = .5
local function equals(t1, t2)
for key, value in pairs(t1) do
if (t2[key] ~= value) then
return false
end
end
for key, value in pairs(t2) do
if (t1[key] ~= value) then
return false
end
end
return true
end
uis.InputBegan:Connect(function(input,typing)
if typing then return end
if not input.KeyCode or input.KeyCode == Enum.KeyCode.Unknown then return end
index += 1
combo[index] = input.KeyCode
--print(combo,combos[1])
--print(equals(combo,combos[1]))
if remove then
task.cancel(remove)
end
remove = task.delay(removal_time,function()
print("removing")
index = 0
table.clear(combo)
end)
end)
I appreciate you all for the help!
I know the post is over, but how would I ‘encrypt’ a key? Would exploiters be able to modify it in the LocalScript? How do I also ‘decrypt’ it?
This is really unnecessary, as UserInputService exists.
Exploiters can edit anything that is on the client, ie local scripts / variables, Physics simulated parts which are network owned by the player, Data sent through remote events from client to server, properities of any object on the client (thats how nocollide hacks work, or super speed run. they just set cancollide on all parts to none and their humanoid walkspeed to very high number). About key encryption you could maybe look into hash functions?
My closest idea would be to maybe SHA256 hash it, then send it to the server. And the server would have a table of hashes for each move and check if they are equal.
SHA256 is an algorithm which generates a string of random numbers from another string, the generated string cannot be decoded back to the original, only checked against.
I know that. I just didn’t want to be too repetitive with the rest of the replies and provided another possible way of doing that.
It might’ve been the best solution if you could move while using the TextBox lol.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.