I was wondering why my keyboard-fired scripts were not working when I noticed that ROBLOX has discontinued the KeyDown/Up events on both Mouse and Gui objects. There is an event "InputBegan" that says I can get an Instance of keydown, but I am unfamiliar with it. I don't know any other ways to doing KeyDown/Up events and the ROBLOX Wiki has no examples of this event being used for keyboard scripts. Can someone show me an alternative method?
I was making a script that would make a pair of wheels spin.
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
Car = game.Workspace.Test
LR = Car.LR.Rim_Default.BodyAngularVelocity
RR = Car.RR.Rim_Default.BodyAngularVelocity
throttle = false
brake = false
clutch = false
function presskey(key)
if key == "w" then
LR.P = 1250
RR.P = 1250
LR.AngularVelocity = (LR.Parent.CFrame * CFrame.new(15,0,0)).p
RR.AngularVelocity = (RR.Parent.CFrame * CFrame.new(-15,0,0)).p
throttle = true
brake = false
end
if key == "s" and throttle == false then
LR.P = 1250
RR.P = 1250
LR.AngularVelocity = (LR.Parent.CFrame * CFrame.new(0,0,0)).p
RR.AngularVelocity = (RR.Parent.CFrame * CFrame.new(0,0,0)).p
brake = true
end
end
Mouse.KeyDown:connect(presskey)

1 comment
Thanks! It seems easy now that I you applied it to my code. I am assuming the InputEnded event works like KeyUp as well.