I put urgent in the title because I really need help with this, and help is very much appreciated, and just so whoever reads this knows, it is a local script.
EDIT: UIS Is UserInputService. which seems kind of obvious I guess but I should probably provide as much information as I can
So I've got some code here, and I was wondering how I would make it so after the KeyCode is pressed, but only if the KeyCode is pressed first, and then the left mouse button is clicked, it would fire the event, instead of just firing the event when the KeyCode is pressed.
UIS.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.Q then -- I'm assuming the left click/mousebutton1 thing would go here game.ReplicatedStorage.Events.Wall:FireServer() end end)
Just add variable to check if "Q" is pressing
Use UserInputType for Mouse and use UserInputState for start and stop pressing
local UIS = game:GetService("UserInputService") local check = false UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.Q then if input.UserInputState == Enum.UserInputState.Begin then --start press check = true elseif input.UserInputState == Enum.UserInputState.End then --stop press check = false end end if input.UserInputType == Enum.UserInputType.MouseButton1 then if input.UserInputState == Enum.UserInputState.End then --only fire when mouse click not mouse down if check == true then game.ReplicatedStorage.Events.Wall:FireServer() end end end end)
Then if it goes there it would be this
UIS.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.Q then UIS.MouseButton1Click:connect(function() game.ReplicatedStorage.Events.Wall:FireServer() end end)
Edit UIS to what ever it is Im not sure but accept if helps