|
| 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 |
|
|
|
| 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 |
|
|
|
| 27 Jun 2014 05:22 PM |
| Interesting method. Thanks :D |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 27 Jun 2014 05:26 PM |
| One variable for each of them! :D |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 27 Jun 2014 07:52 PM |
Use next then ;)
for i, v in next, tab do |
|
|
| Report Abuse |
|
|