Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

MouseButton2 Click how to do it? help pls ( Advance )

When you hold right mouse button you scope in with a gun I only know how to do that with a key, but how to do it with mouse?

Player = game.Players.LocalPlayer
mouse = Player:GetMouse()

if mouse then
mouse.KeyDown:connect(function(key)
if key== "c" then	
		
	print("Test")
	
	  end
	end)
end

3 comments

0

this is a pretty basic topic considering I understand how to do it, maybe you should research a little instead of just asking the answer is everywhere

0

Fero can u help me i have been researching for a day and cant get my turret to work. I made it shoot, but the bullet just flopps down i added a body thrust but if i make target offset not make it flop it will curve and go somewhere i dont want it to go

0

I'd love to help if I could, but I'm only a beginner I started when we were put under quarantine, I don't have the slightest understanding of ray casting, and am learning about that now, I'd go to the roblox devforum and post your question there

1 answer

✓ Accepted answer

Here see if this works

UserInputService.InputBegan:Connect(function(Input)
    if Input.UserInputType == Enum.UserInputType.MouseButton1 then
        -- mouse
    elseif Input.UserInputType == Enum.KeyCode.ButtonR2 then
        -- R2
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.