Im having problems trying to get two keybinded controls working together, this is the first one, its in a localscript:
local player = game.Players.LocalPlayer
local char = player.Character
local space = game.Workspace
local animal = space:WaitForChild(char.Name.."2")
local ContextActionService = game:GetService("ContextActionService")
function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
print("button pressed")
animal.Vitals.Heart.Control.ForwardTrig:FireServer()
script.Parent.StopW.Disabled = false
wait()
script.Disabled = true
end
end
ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.W)
and this is the second one:
local player = game.Players.LocalPlayer
local char = player.Character
local space = game.Workspace
local animal = space:WaitForChild(char.Name.."2")
local ContextActionService = game:GetService("ContextActionService")
function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
print("button pressed")
animal.Vitals.Heart.Control.BackwardTrig:FireServer()
script.Parent.StopS.Disabled = false
wait()
script.Disabled = true
end
end
ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.S)
both scripts turn on when the key is down and activate a stopping localscript to stop an action when the key is released. if one script is enabled and the other is disabled, the enabled script runs, and vice versa. however if both are enabled only one will respond, the other will not fire unless the other is turned off.
