Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Issue with the ROBLOX KeyBoard Input, no KeyUp Detection?

Asked by
movsb 242 Moderation Voter
8 years ago

So I am basically making my own control script for the roblox character, and I am having an issue in the keyboard input, what I am trying to do is when the player's "W" key goes down, make the player's characters torso go forward until the "W" key goes up. I am having trouble finding when the "W" key goes up, and I am pretty frustrated as roblox does not seem to have any method or function able to find when a key goes up. Here is the local control script so far:

local r     = game:GetService("ReplicatedStorage"):WaitForChild("Control");
local uis   = game:GetService("UserInputService");
local cas   = game:GetService("ContextActionService");
uis.InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.W then
        r:FireServer("W");
    end
end

When r (the remote event) fires the server the "W" string, the server script will make the character move forward according to the torso's lookVector. This works great, but it only moves forward one time when the w key is down. I am trying to get the character to continue moving forward while the w key is down, and halt movement when the w key goes up. Any help would be appreciated a lot. Thanks

1 answer

Log in to vote
0
Answered by 8 years ago

Are you looking for InputEnded ???

Example:

game:GetService("UserInputService").InputEnded:connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.W then
        --put ur stuff here
    end
end)
0
no, because UserInputService does not register a key being held down as continuous input. Thankfully I found out the GetKeysPressed() function, which helps a lot. Thanks for trying to help tho! movsb 242 — 8y
Ad

Answer this question