Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a script of weapon switch using scroll?

Asked by 4 years ago

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!

0
You mean something like this? https://gyazo.com/bd5fabe98e5daef0f4f2805fcca091e0 AspectType 151 — 4y
0
yep like that eromusics 10 — 4y
0
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. AspectType 151 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago
Edited by royaltoe 4 years ago

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
)

0
you should instead be using the mod operator. currentSlot = currentSlot % max + 1 davidgingerich 603 — 4y
0
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. eromusics 10 — 4y
0
localscript inside of weapon royaltoe 5144 — 4y
Ad
Log in to vote
0
Answered by
n_ubo 29
4 years ago

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.

0
But do you know where to put the script like : serverscriptservice or serverstorage? eromusics 10 — 4y
0
scs n_ubo 29 — 4y
Log in to vote
-1
Answered by
Robowon1 323 Moderation Voter
4 years ago

https://scriptinghelpers.org/questions/37016/detecting-the-direction-the-mouse-wheel-is-moving

Answer this question