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: Editing a value in an array

Previous Thread :: Next Thread 
james8tg is not online. james8tg
Joined: 25 Mar 2010
Total Posts: 229
25 Jul 2017 02:57 AM
Just a quick question,

I have an array setup with four values inside - say I wanted to change the value of Array[3], how would this be achieved?

Thanks,
James
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
25 Jul 2017 03:17 AM
Array[3] = blah
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
25 Jul 2017 03:56 AM
local Array = {"value", "not a value", "property", "you went too far"}

local value_that_we_think_is_at_the_third_index = nil
local edit_value_at_third_index_in_Array = nil

edit_value_at_third_index_in_Array = function(new_value)
for k,v in pairs(Array) do
if k > 0 and k == 3 and k % 3 == 0 and k <= #Array then
if v ~= nil and v == v and v then
if value_that_we_think_is_at_the_third_index == nil then
value_that_we_think_is_at_the_third_index = v
edit_value_at_third_index_in_Array(new_value)
else
if value_that_we_think_is_at_the_third_index == v then
if not false then
if new_value ~= value_that_we_think_is_at_the_third_index then
Array[3] = new_value
print("The value at the third index of the Array is now: "..tostring(new_value))
else
error("Attempted to set the third index to the same value. Value not changed.")
end
end
end
end
end
end
end
end
edit_value_at_third_index_in_Array("new property")
Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
27 Jul 2017 05:50 AM
while true do end
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
27 Jul 2017 05:55 AM
while thruse do


Report Abuse
DevJoas is not online. DevJoas
Joined: 17 Dec 2014
Total Posts: 627
27 Jul 2017 05:57 AM
@amanda

That's probably the best script I've ever seen :O
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