Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I make a time value save?

Asked by 8 years ago

So, this is what I want to do but I have no idea on how I could do it efficiently. Let me give a scenario similar to mine. Say you walk up to a machine to repair. When you touch it, a Gui pops up. When you press "e" the Gui counts down from 5 - 1. When you walk away, it resets unless it was repaired. Now there are hundreds of these machines and making an individual value for every one of these is absurd. The gui is cloned from the machine to the players playergui from a script in the model. I already know how to do all of this, but how would I make it to where if you walked away from the machine (the gui would destroy itself.) how would I make it to where it would save itself?

0
~I saw you on the forums~ xxxXMrsAwesomeXxxx 70 — 8y
1
I saw you aswell xXLegendarySoldierXx 129 — 8y
0
/wave xxxXMrsAwesomeXxxx 70 — 8y
0
I am really in a pickle with this. xXLegendarySoldierXx 129 — 8y
View all comments (2 more)
0
You could create an intValue with Instance.new() and put it in the machine when the player walks away? This looks complex and dificult to understand regardless of the explanation. GoldenPhysics 474 — 8y
0
I think I can figure out a way based off of this. Thanks1 xXLegendarySoldierXx 129 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

My recommendation is this: Have an intValue inside each machine called "repairTime" or something similar. This will be how you save the time.

OR if you don't want to do the work of putting a value inside each machine (hundreds you say?) what you can do is just have a function inside the script to do this when you walk up to the machine:

  1. Check the machine for a "repairTime" value
  2. If its NOT there, create it `Instance.new("IntValue"), make it's parent the machine
  3. Now that "repairTime" exists in the machine go thru the countdown [Each time the counter goes down by 1, "repairTime" also goes down by one. If the person walks away, the counter stops and "repairTime" stays at whatever number it was left at]

Does this make sense?

Ad

Answer this question