Hello devs! I am wondering, is there any way, to replicate any key (Enum.KeyCode) client side?
Thanks for responding!
Hello devs! I am wondering, is there any way, to replicate any key (Enum.KeyCode) client side?
Thanks for responding!
you mean like this?
--- in a local script
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode. --- Key
then
-- script here
end
end)
Are you wanting to replicate it from the client to the server? There wasn’t exactly much information you stated in your OP
If you’re asking if you can do Enum.KeyCode
client sided, your answer is yes. In fact, you can only use Enum.KeyCode
on the client. If this is not what you’re asking, please provide more information on what you’re talking about.
local k = Enum.KeyCode
input.Keycode == k.E
?
No, the Enum library does not lock members on different context’s I believe. Even if they did, Enum.KeyCode
is not one of them.
No, I need to know if there is way to replicate pressing key.
Hey, you’ll want to be more specific than that or you won’t get very much help, being intentionally vauge helps nothing and nobody. I assume you mean you want the server to send the client Enum.KeyCode
I do not know why you would want to do this, but you can:
remote:FireClient(player, Enum.KeyCode.Blah)
And then recieve the remote as usual.
I need to know if theres a way to make player automatically press a key! Like W, but player does not have to press it.
Are you trying to disable W along with it?
No, and it has not to be W, it can be any key.
Try this out
I dont want to make player move, I want to player replicate player pressing key.
We are not getting what u mean.
Basically heres what I would do
If you want ur keys to be public
game.ReplicatedStorage.CallKey.OnServerEvent:Connect(function(plr,key)
print(plr.Name, "pressed",tostring(key))
end)
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
game.ReplicatedStorage.CallKey:FireServer(input.KeyCode)
end)
Expected output:
i want to player automatically press KEY, that means like on phone, you can replicate pressing for example key SHIFT.
And now we all have solution to ur topic .
In simple words:
Not able to do with roblox. This isn’t a Macro/Auto-Key/Auto-Hotkey Software.
The only thing you could do for phones is like
calling the scripts automaticly per seconds per timers, or when the phone person does sth.
, but not per doing sth like User:PressKeyCode(Enum.Keycode.E)
I guess there is no solution for this :/.
You could use
if plr is playing on phone since I guess “Shift” for running, so that they are automaticly running.
using
local UIS = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")
if UIS.TouchEnabled and not UIS.KeyboardEnabled and not UIS.MouseEnabled
and not UIS.GamepadEnabled and not GuiService:IsTenFootInterface() then
-- mobile device
end
Instead of forcing player to use a key, you could force call whatever function you have tied to that keypress, e.g context action service bind