What is the mouse wheel key binding ? I want to switch guns through mouse wheel button but could'nt find it on key binding list. Any help would be great !
While I do not know of a specific key binding, you could grab the "currentDistance" from the camera because that is controlled by the mouse wheel. For example, the script below will detect changes in the camera distance and broadcast an event "Mouse Wheel Changed" whenever the player scrolls the mouse wheel. Don't forget to set the camera's distance to adjustable
--Save the current distance property of the player's current camera local originalDistance = Game.GetLocalPlayer():GetActiveCamera().currentDistance function Tick(deltaTime) --Get the player's current camera local currentCamera = Game.GetLocalPlayer():GetActiveCamera() --Check if the camera's distance has changed if(currentCamera.currentDistance ~= originalDistance) then --Get the change local change = currentCamera.currentDistance - originalDistance --Broadcast an event so that other scripts know that the mouse wheel changed Events.Broadcast("Mouse Wheel Changed", change) --Reset the distance currentCamera.currentDistance = originalDistance end end
Thank you so much ! I'll try this one, hope I can make it work ! :)))
Rolling the mousewheel generally controls the camera and pressing it opens the window to change avatars. I think it's reserved for those functions.
A bit old, but might be useful for others in need.
A more efficient method :
local LocalPlayer = Game.GetLocalPlayer() -- Capture wheel event (Zoom) function OnActionPressed(player, action, value) if (player == LocalPlayer) then -- wheel event = "Zoom" if action == "Zoom" then -- Scroll wheel will either be -1 or 1. if value > 0 then -- Your stuff here... elseif value < 0 then -- and there. end end end end -- handler params: Player_player, string_action, numeric_value Input.actionPressedEvent:Connect(OnActionPressed)