I've looked around and couldn't find anything, but I basically mean if there's a way to do something like
Part:Change('Transparency', 0.75)
If this doesn't make sense I'm sorry, I'll try to answer any questions.
I've looked around and couldn't find anything, but I basically mean if there's a way to do something like
Part:Change('Transparency', 0.75)
If this doesn't make sense I'm sorry, I'll try to answer any questions.
Properties of a userdata value are handled like indices. In other words, while this works...
part.Transparency = 1
...this also works:
part["Transparency"] = 1
In fact, because userdata properties are handled as if the userdata was a table (which they actually are), you can do this with quite literally any property. Unfortunately you can't tell the compiler to explicitly treat a userdata like a table.
However, since userdata values aren't explicit tables, something like this doesn't work:
print(#workspace.Baseplate)
But this does:
print(workspace.Baseplate["BrickColor"])
With that being said, you can make a table of strings for each specific Instance and check to see if that exists in the userdata:
local partProperties = {"Size", "BrickColor", "Transparency", "Parent"}
local rand = partProperties[math.random(1, #partProperties)]
if workspace.Baseplate[rand] then -- This actually works
print(workspace.Baseplate[rand])
end
That is how you would assess it.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Why exactly you need this?
I'm trying to make it where in a game you can put a number or bool value inside a part and it sets the parts value (Name of the part) to the value of the variable, eg. a number value called Transparency with a value of 0.75