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!
How to make a script of weapon switch using scroll?
3 answers
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
)
3 comments
you should instead be using the mod operator. currentSlot = currentSlot % max + 1
Um do you know where to put like the local script or just the script and Where to make the script like the serverstorage or serverscript service. Im a bit dumb here.
localscript inside of weapon
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.
2 comments
But do you know where to put the script like : serverscriptservice or serverstorage?
scs
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
You mean something like this? https://gyazo.com/bd5fabe98e5daef0f4f2805fcca091e0
yep like that
Okay, this took me ~1 hr 30 min. You will need to use ContextActionService. I don't advise using Mouse.WheelForward or Mouse.WheelBackward, as it can cause errors and it should not be used in new work.