Custom Properties

Hey guys,
hope you guys are having a nice day.
I have a quick question, is it possible to make own properties?
I have tried with moduleScripts but its very complicated and i dont rlly get the hang of it. If anyone knows comment down below! :smiley:

Regards to yall

Hello :wave:

It is possible to make custom properties.
However they are called “attributes”.
You can create attributes for every Instance

About attributes: Instance Attributes

If you want to make a ball bounce you could add a “bouncyness” attribute and give some value, depending on the value the ball bounces higher/ longer/ etc. However the script that controls how the ball bounces has to be created by you as well.

I hope this is useful for you.
Have a great day

-DosenSuppe

3 Likes

Does it also work for the variables? Like an own method?

Example
The method would be to change a text and i would name the method :foo
Then i can just call the function:
textLabel.Text:foo()

or print something

method would be print
and i would just do some variable and then add :foo

local function is not what i mean.

You can’t make your own class properties, but you can Attributes as mentioned before, or you can use Metatables.

1 Like

I just figured it out lol

local foo = {
Method = print
}

scirpt:foo(„bar“)

Prints bar using the foo method

What are you trying to do here, huh? That’s not gonna work.

Im sorry, i meant

local foo = {
Method = print
}

foo:Method(„bar“)

Prints „bar“

Oh gosh this sounds very complicated (metatables)

By foo:Method("bar"), you’re actually doing the equivalent of:

foo.Method(foo, "bar")

which means

print(foo, "bar")

and is not the same as

print("bar")