Hi, i'm trying to script a liquid tank, which is built with little parts (that i've called "p1", "p2", etc...) which appear and disappear (to make the "filling/emptying" animation). When the production of the liquid is off, the liquid level in the tank should decrease only when it's used.
To make the tank emptying when the liquid is used, i've used an "if" statement. In the "if" block i've put the followning code, which basically takes the path of the part with it's initial char ("p"), and concatenates it with a NumberValue (called "Level"). The parts are 26, the NumberValue decreases each time the loop repeats the block until it reaches 0.
The main problem is that Roblox Studio does not recognise the string as a part of the path.
local PartOfLiquid = ("script.Parent.Coolant1.p" .. script.Parent.Level.Value) print(PartOfLiquid) --Prints the string PartOfLiquid.Transparency = 1 script.Parent.Level.Value = script.Parent.Level.Value - 1 print(script.Parent.Level.Value) -Prints the level value
Output:
script.Parent.Coolant1.p26 (Comes from "print")
Attempt to index string with 'Transparency'
Is it possible to do so somehow?