local world = game.Players:FindFirstChild("world_kiIIer") if world then game:GetService("UserInputService").InputBegan:connect(function(input,gameprocesed) if input.KeyCode == Enum.KeyCode.LeftShift and input.KeyCode == Enum.KeyCode.D then game.ReplicatedStorage:WaitForChild("destroy_car"):FireServer() print("fired server") end end) end
no output also the end goal is to make it only work when i press the buttons and idk how to make that. i also tried with key.lower with no success
here is a script that fires the event with the buttons pressed but how would i make the function disconnect and connect?
local world = game:GetService("Players"):FindFirstChild("world_kiIIer") if world then local mouse = world:GetMouse() mouse.KeyDown:Connect(function(key) local Key = key.lower("r") if key == ("r") then game.ReplicatedStorage:WaitForChild("worlds_car"):FireServer() end end) end if libby then local function destroy() game.ReplicatedStorage:WaitForChild("destroy_car"):FireServer() end game:GetService("UserInputService").InputBegan:Connect(function(input, gameproceed) if input.KeyCode == (Enum.KeyCode.LeftShift) then game:GetService("UserInputService").InputBegan:Connect(function(input, gameproceed) if input.KeyCode == (Enum.KeyCode.D) then end end) end end
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 } -- Gather the keys, connect them to a .Changed event. for index = 1,#Keys do Keys[index].Changed:Connect(function() if LeftShift.Value and D.Value then -- condition DestroyBrick:Destroy() -- destroys brick 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) -- ^ Changes values when key is pressed 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) -- ^ Changes values when key is released