generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Item Toggle [Table]

Previous Thread :: Next Thread 
zedix123 is not online. zedix123
Joined: 29 Mar 2012
Total Posts: 91
16 Jul 2015 08:10 PM
This script is for a right arrow button to toggle the items on sale in a shop gui in order, the ShopSwordID is a stringValue, and the alphabet is it's value which identifies the item shown currently on the shop. (Like A = Sword1, etc. till E) Is there any way to restart this process?

-------------------------------------------------------------------------------------
local AlphaTable = {"A","B","C","D","E"}

local n = script.Parent.Parent.ToggleVariable.Value -- linked to a NumberValue outside

function onClicked()
script.Parent:FindFirstChild("ClickSound"):Play()
n = n + 1 -- Adds 1 to the current table index position, (A to B, B to C etc.)
script.Parent.Parent.ShopSwordID.Value = AlphaTable[n] -- The alphabet value of the string is changed.
script.Parent.Parent.ToggleVariable.Value = n --return the current n value
end

script.Parent.MouseButton1Down:connect(onClicked)
-------------------------------------------------------------------------------------

Also, when I try "n = n - 1" (in line 7) for the left arrow, it doesn't work at all. Help?
Report Abuse
zedix123 is not online. zedix123
Joined: 29 Mar 2012
Total Posts: 91
16 Jul 2015 08:14 PM
I already took care of the restart cycle. But the left arrow still doesn't work. Just need help with that.

--Current Script:-
local AlphaTable = {"A","B","C","D","E"}

local n = script.Parent.Parent.ToggleVariable.Value

function onClicked()
if n < 5 then
script.Parent:FindFirstChild("ClickSound"):Play()
n = n + 1
script.Parent.Parent.ShopSwordID.Value = AlphaTable[n]
script.Parent.Parent.ToggleVariable.Value = n
elseif n == 5 then
n = 1
script.Parent.Parent.ToggleVariable.Value = 1
script.Parent.Parent.ShopSwordID.Value = AlphaTable[n]
end
end

script.Parent.MouseButton1Down:connect(onClicked)
Report Abuse
zedix123 is not online. zedix123
Joined: 29 Mar 2012
Total Posts: 91
16 Jul 2015 08:18 PM
Bump.
Report Abuse
zedix123 is not online. zedix123
Joined: 29 Mar 2012
Total Posts: 91
16 Jul 2015 08:28 PM
Output error.

06:28:08.062 - Players.Player1.PlayerGui.ShopGui.ShopContainer.ImageButton:8: bad argument #3 to 'Value' (string expected, got nil)
06:28:08.063 - Script 'Players.Player1.PlayerGui.ShopGui.ShopContainer.ImageButton', Line 8
Report Abuse
zedix123 is not online. zedix123
Joined: 29 Mar 2012
Total Posts: 91
16 Jul 2015 08:59 PM
Fixed. Took an half an hour though.

local AlphaTable = {"A","B","C","D","E"}

local n = script.Parent.Parent.ToggleVariable

function onClicked()
if n.Value < 5 then
script.Parent:FindFirstChild("ClickSound"):Play()
n.Value = n.Value + 1 -- Adds 1 to the current table index position, (A to B, B to C etc.) and variable value.
script.Parent.Parent.ShopSwordID.Value = AlphaTable[n.Value] -- Check alphabet on current position of n (1 = A, 2 = B and onwards..)
elseif n.Value == 5 then -- If viewing the last item, restart process on next click.
script.Parent:FindFirstChild("ClickSound"):Play()
n.Value = 1 -- Back to the first item
script.Parent.Parent.ShopSwordID.Value = AlphaTable[n.Value]
end
end

script.Parent.MouseButton1Down:connect(onClicked)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image