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

how can i scroll trough my backpack? [closed]

Asked by 7 years ago

So i want that if you scroll forward / backward you change your gun to the next gun so if u have 2 guns if u have the main selected and if u scroll then it changes to ur secondary and then if u scroll again it goes back to ur main! code:

local Player = game:GetService("Players").LocalPlayer;
local Backpack = Player:WaitForChild("Backpack");
local Mouse = Player:GetMouse();
local text = "Changing Weapon";
local Character = Player.Character;
local Hum = Character:WaitForChild("Humanoid")

local ChangeWeapon = function()
    print(text);
    local Guns = Backpack:GetChildren();
    for i=1, #Guns do
        Hum:EquipTool(Guns[1]);
    end
end

local ChangeWeapon1 = function()
    print(text);
    local Guns = Backpack:GetChildren();
    for i=-1, #Guns do
        Hum:EquipTool(Guns[1]);
    end
end

Mouse.WheelForward:connect(function()
    ChangeWeapon()
end);


Mouse.WheelBackward:connect(function()
    ChangeWeapon()
end);

this does not work! D: (asking again since it got moderated =,=)

1
If your question gets locked or moderated for any reason, do not repost the same question. Make sure you make the necessary changes to the question to fit the advice the moderation message provided and then post it. Do not post requests, off-topic, spam, or duplicate content. hiimgoodpack 2009 — 7y
0
Also, I really don't get your code. hiimgoodpack 2009 — 7y
0
Post errors and describe what is or isn't happening. What I see at first glance is you're indexing '1' on lines 12 and 20 so the result will never be different. Goulstem 8144 — 7y
0
+1 to omit moderation rep loss. Explain this better mate. Goulstem 8144 — 7y

Closed as Non-Descriptive by Goulstem

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?