Virtual user press space key

game:GetService(“VirtualUser”):SetKeyDown(“space”)
But i want it working.

1 Like

Any other way you can make a script that can do that? Its for admin commands im trying to make.

For what purpose is it needed?

How about instead you tell us why you are using it? There are other ways to make someone jump, if that’s all you want.

I just want a admin commands command that can make you press any key repeatedly.

I don’t know of any other way to do that

I did some recording and I found out it is not using “E” or “SPACE” but some type of symbols
virtualUser:CaptureController()
wait(0.185089)
virtualUser:Button1Down(Vector2.new(0.0663233, -0.603571), CFrame.new(0, 7.93524, 12.0741, -0.130526, 0, 0, 0.991445))
wait(0.081877)
virtualUser:Button1Up(Vector2.new(0.0663233, -0.603571), CFrame.new(0, 7.93524, 12.0741, -0.130526, 0, 0, 0.991445))
wait(0.33304)
virtualUser:SetKeyDown(‘0x77’)
wait(0.500988)
virtualUser:SetKeyDown(‘0x61’)
wait(0.716011)
virtualUser:SetKeUp(‘0x61’)
wait(0.600991)
virtualUser:SetKeyDown(‘0x64’)
wait(0.448997)
virtualUser:SetKeUp(‘0x77’)
wait(1.00101)
virtualUser:SetKeyDown(‘0x73’)
wait(0.366)
virtualUser:SetKeUp(‘0x64’)

it is UTF-8? i guess Unicode/UTF-8-character table

The “string” input argument in the VirtualUser methods - TypeKey, SetKeyDown, SetKeyUp - are virtual key codes.

The above link provides the virtual keycode corresponding to the spacebar: “0x22”.
Thus, the simple code to invoke a single jump would be the same code as provided in the question with the “space” replaced by “0x22”: game:GetService("VirtualUser"):SetKeyDown("0x22");

Note: You must release the key for the user to stop jumping: game:GetService("VirtualUser"):SetKeyUp("0x22");

Here is a function I wrote that simulates a single jump. The script signal will wait until the user has landed before continuing.

local function SimulateJump()
    local Humanoid = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid")
    game:GetService("VirtualUser"):SetKeyDown("0x20");
    task.wait(0.1);
    game:GetService("VirtualUser"):SetKeyUp("0x20");
    repeat task.wait() until Humanoid:GetState().Value == 7; -- wait until state is "Landed"
end

SimulateJump()
1 Like