#Setting properties to parts inside a model

30 messages · Page 1 of 1 (latest)

paper echo
#

Hi!
Im having some issues with a script i wrote to set the properties of parts inside a model to some value.
however, the issue im facing is that when i actually get to setting it, it just resets back to it's original state for some reason-

function helper.ModelAppearance(model, appearanceProperty, value)
    
    for _,obj in pairs(model:GetChildren()) do
        -- append the appearance property i wanna change to the end of the path
        local modified = obj:GetFullName().."."..appearanceProperty
        
        -- convert the string back into an actual object 
        local target = helper.StringTarget(modified)
        
        -- but for some reason it wont set it???
        target = value
    end
end

Here's some console output logged after i added print statements to help me debug:
[image 1: setting the model's transparency to 1, invisible]
[image 2: setting the model's transparency to 0, visible]

The console output is a print before and after each variable set (except for target).

"Original" and "Modified" are the before and after of modified
I convert the path to the model into a string and append the appearanceProperty variable to the end

"Target" and "Target Type" print out target's path and type
Here I convert the string back into an object

"Value before" and "Value after" are the before and after of target = value
Here I just set the targeted property to the given value

surreal carbon
#

what am i reading here on the Prints

magic flint
#

What am I looking at

paper echo
#

i think it would've been better if i had used the version of the code with prints.. or maybe included an explanation of what they are-

paper echo
surreal carbon
#

lol looks like u have Discord Nitro

magic flint
#

What is this supposed to do?

magic flint
surreal carbon
#

lol same but its not showing up for me

paper echo
# magic flint What is this supposed to do?

yknow how models dont have stuff like transparency? well instead of having to have a loop for every property you wanna change, you have neat little function that can work with any property you wanna set to the parts inside a model

reading that back, it didn't make much sense, but i hope it does make some to you

magic flint
#

But why the modified variable

#

It woulnt work anyways

paper echo
#

why?

surreal carbon
#

finally

magic flint
#

You could have just instance[string/property] = something

#

Since every instance is a table

paper echo
#

w h a t

magic flint
#

Because you know, lua

surreal carbon
#

lol almost everyone knows Lua

paper echo
#

i

magic flint
#

Lua only have one data storage thing that is naive to it which is tables

#

Everything in the game is made out of tables, metatables to be exact

paper echo
#

i just realized i've done an all nighter for nothing
well i guess not really, since i learnt something new

#

i still feel very dumb though

#

well here's the updated function for anyone that might need it (which i doubt)

function helper.ModelAppearance(model, appearanceProperty, value)

    for _,obj in ipairs(model:GetChildren()) do
        
        obj[appearanceProperty] = value
        
    end
end
magic flint
#

lol

paper echo
#

i forgot that existed

#

whoops