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

Holding down a key?

Asked by 8 years ago

Hey guys.

I made the following script. What I want it to do is move a little bit per key press. What it does is when you press A, it moves to a new position. What it's supposed to do is when you hold it down, it moves to the left . Any help?

script.Parent.Parent.Parent.PrimaryPart = script.Parent.Parent.Parent.Base.basec
Player = game.Players:GetPlayerFromCharacter(Player)

function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.A then
        script.Parent.Parent.Parent:SetPrimaryPartCFrame(CFrame.Angles(0,0.1,0))
        wait(0.1)
    end
end


game:GetService("UserInputService").InputBegan:connect(onKeyPress)

Thanks

Answer this question