|
| 04 Jun 2012 08:34 PM |
I have this script that changes the name of a model by the value of an IntValue named health. So. Say the model's name is [25], that is because the IntValue i have in a seperate location is 25. My plan was, that when the IntValue decreased, it changed the name of the Model. Example.
IntValue = 25 model name = 25 -1 IntValue = 24 model name = 24 -1 IntValue = 23 model name = 23
I know the IntValue is decreasing, but the model name isnt changing. My script is
while true do script.Parent.Name = ""..script.Parent.Parent.Door.Door1.Health.Value.."" return end
This works. I know it works because when i go into a game, the model name changes to 25, but as the IntValue decreases, the model name doesn't. What is wrong? |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 08:36 PM |
script.Parent.Parent.Door.Door1.Health.Changed:connect(function() script.Parent.Name = tostring(script.Parent.Parent.Door.Door1.Health.Value) end)
Just to make it more efficient, as for the name, try checking if its script.Parent.Parent instead of script.Parent...? |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 08:37 PM |
| You can't set variables as numbers. |
|
|
| Report Abuse |
|
|
| |
|
|
| 04 Jun 2012 08:40 PM |
| I don't remember variables owning the capability of having a number set to it. |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 08:41 PM |
Hello1HowAreYou = "trololol?"
print(Hello1HowAreYou)
As long as the first character is not a number its fine... |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 08:43 PM |
no no I mean this:
variable = 1
print(variable) |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 08:43 PM |
Actually:
getfenv()["1234Trololol"] = "Trolling with dem mindz" print(getfenv()["1234Trololol"]) |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 08:45 PM |
modelname = IntValue
IntValue = 25 modelname = IntValue wait(1) IntValue = 24 modelname = IntValue wait(1)
Like that?
There are other ways to do this, but this is the simple way. |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 08:45 PM |
._. Really?
Number is one of the data types, print(type(1)) will prove this. You can store anyyyyyyyyything in variables as long as it exist (or even if it doesn't, proven by a = nil print(a) print(type(a))). So yeah, you can store numbers in variables...
a = 1 b = 2 c = a + b print(c) |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 08:50 PM |
| @Ele, worked thanks bro. :) |
|
|
| Report Abuse |
|
|