Hi guys! I'm new to the roblox studio and a really newbie there. I'm trying to make a FPS game so OFC we need to script about the scroll switch. But I don't know. The youtubes videos are outdated. Is there somebody know how to? Please tell me the script and where to put it. Thanks! Btw the game is already published. Game : https://www.roblox.com/games/4498440039/Countrys-calling Please try it! It helps alot!
Keep in mind: only do this for first person games because with third person games, you use the scroll wheel to move camera in/out.
You can can use the Mouse.WheelForward
and Mouse.WheelBackward
events to get which direction the scroll wheel is moving.
I'll make a short example of how to set this up so it moves through 10 slots (not actually though it's just a variable)
local currentSlot = 1 local Players = game:GetService("Players") local Mouse = Players.LocalPlayer:GetMouse() Mouse.WheelForward:Connect( function() if currentSlot < 10 then currentSlot = currentSlot + 1 else currentSlot = 1 end end ) Mouse.WheelBackwards:Connect( function() if currentSlot > 1 then currentSlot = currentSlot - 1 else currentSlot = 10 end end )
I tried this a lot of tiems i have a script that does work, but it chances not to the next number weapon in the hotbar, but to a random one.
https://scriptinghelpers.org/questions/37016/detecting-the-direction-the-mouse-wheel-is-moving