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 » Scripting Helpers
Home Search
 

Re: Getting the before value.

Previous Thread :: Next Thread 
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
27 Jun 2014 05:07 PM
--Assuming it was in a StringValue
script.Parent.Changed:connect(function(v)
print(v)
end)

script.Parent.Value = "Hello"

->Hello


How would I get what it equaled BEFORE it was changed. I'll accept any 'hacky' way or 'ugly' possibility, if that is the only way you can think of.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
27 Jun 2014 05:09 PM
local previousValue = nil

script.Parent.Changed:connect(function(v)
print((previousValue and "PREVIOUS: " .. previousValue .. " CURRENT: " or "") .. v)
previousValue = v
end)


script.Parent.Value = "Hello"
script.Parent.Value = "World!"
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
27 Jun 2014 05:22 PM
Interesting method. Thanks :D
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
27 Jun 2014 05:25 PM
I actually got to do this with multiple ObjectValues so how would this work? (There are 4 of them)
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
27 Jun 2014 05:26 PM
One variable for each of them! :D
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
27 Jun 2014 07:33 PM
I'm iterating... Here is an example of the thing I'm doing


for _,v in ipairs(Things:GetChildren()) do
v.ObV.Value.ObVal.Changed:connect(function()
--HELP ME
end)
end
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
27 Jun 2014 07:37 PM
local prevVals = {}

for i, v in next, Things:GetChildren() do --ipairs is 17% slower than next! Do not use!
prevVals[i] = v.ObV.Value.ObVal.Value --What is this!?
v.ObV.Value.ObVal.Changed:connect(function(newVal)
print(tostring(prevVals[i]) .. " was the previous value, now its " .. tostring(newVal))
prevVals[i] = newVal
end)
end
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
27 Jun 2014 07:52 PM
I could have done that. But, hey, I gave you something to do XD

Oh, and I'm used to ipairs. I try to stop but it's instinct to hit the keys I p a I r s.

Dumb auto capitalizing I's...
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
27 Jun 2014 07:52 PM
Use next then ;)

for i, v in next, tab do
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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