Second Image, I want it to go from the first gun in example, AK47 all the way down to Uzi (not shown)
if it would pass uzi, it would go again to AK47 etc.
Heres a video showing that how it changes the guns. It is already done, but now how can I make it change to the next on the gun list?
Hello! Here’s a simple example script for an interface that allows you to select and scroll through weapons by pressing arrow buttons:
local gui = script.Parent
local weaponList = {
"Pistol",
"Shotgun",
"Assault Rifle",
"Sniper Rifle"
}
local currentWeaponIndex = 1
-- Function to update displayed weapon
local function updateWeaponDisplay()
gui.WeaponLabel.Text = weaponList[currentWeaponIndex]
end
-- Initial update of weapon display
updateWeaponDisplay()
-- Function to scroll to the next weapon
local function nextWeapon()
currentWeaponIndex = currentWeaponIndex % #weaponList + 1
updateWeaponDisplay()
end
-- Function to scroll to the previous weapon
local function previousWeapon()
currentWeaponIndex = (currentWeaponIndex - 2 + #weaponList) % #weaponList + 1
updateWeaponDisplay()
end
-- Event handlers for arrow buttons
gui.LeftButton.MouseButton1Click:Connect(previousWeapon)
gui.RightButton.MouseButton1Click:Connect(nextWeapon)
This script assumes you have a GUI with two arrow buttons (e.g., LeftButton and RightButton) and a text element (e.g., WeaponLabel) where the currently selected weapon will be displayed.
When you click the left arrow button (LeftButton), the previous weapon in the list will be selected, and when you click the right arrow button (RightButton), the next weapon in the list will be selected.