First, learn to indent. It makes code more read-able. You have 2 keycode conditions which aren't going to work the way you want.
For clarity, here's a simple way of achieving the result you want which involves 2 boolean values:
local LeftShift = Character:WaitForChild("LeftShift")
local D = Character:WaitForChild("D")
local DestroyBrick = workspace:WaitForChild("DestroyMe")
local Keys = {
LeftShift,
D
}
for index = 1,#Keys do
Keys[index].Changed:Connect(function()
if LeftShift.Value and D.Value then
DestroyBrick:Destroy()
end
end)
end
UserInputService.InputBegan:Connect(function(Input,GameProcessedEvent)
if not GameProcessedEvent then
if Input.KeyCode == Enum.KeyCode.LeftShift then
LeftShift.Value = true
elseif Input.KeyCode == Enum.KeyCode.D then
D.Value = true
end
end
end)
UserInputService.InputEnded:Connect(function(Input,GameProcessedEvent)
if not GameProcessedEvent then
if Input.KeyCode == Enum.KeyCode.LeftShift then
LeftShift.Value = false
elseif Input.KeyCode == Enum.KeyCode.D then
D.Value = false
end
end
end)
2 comments
I believe the reason this doesn't work is because when you fire the function connected to your InputBegan event, it only has the one input parameter, which can't be two different inputs, (keypresses in this example). I unfortunately don't know a solution at the moment, but I can do some research to try and find you an answer.
Put the if statement inside of your event