#Is there a way to make multiple parts have the same script, but script aswell have unique variables.

1 messages · Page 1 of 1 (latest)

hollow citrus
#

Insight:
So, I'm making a cube fusion type game, basically a bunch of cubes, fuse them, make a bunch of items
while the script i have runs great now, editing each cube whenever i want to make a change will most likely make this game way harder to create.

problem:
How do i give each cube a easily editable script but aswell able to have different variables and tables.

jolly obsidian
#

just have one main controller

#

that will keep track

hollow citrus
jolly obsidian
#

so you can just

#

easly keep track of properties

#

and loop to connects touched or whatever you need

hollow citrus
jolly obsidian
#

ye

hollow citrus
#

ok 🤔

jolly obsidian
#

when spawning you can either tag them

#

or just

#

spawn then in same script

#

so you can add to table right away

hollow citrus
mossy mango
hollow citrus
green torrentBOT
#

studio** You are now Level 1! **studio

jolly obsidian
#

tag i meant collectionservice

#

so you can get all parts easly

#

then just have values[table] = {]

hollow citrus
#

or wait, realized i worded that message wrong:
How to make sure each tag cube has a different dictionary

jolly obsidian
#

dir[cube] = {}

#

i typed prev wrong

#

you just use cube (instance) as index

hollow citrus
#

cube is the name 🤔?

#

name variable

jolly obsidian
#

why not use instances

#

as indexes

hollow citrus
#

i was asking a question
but i used names because i continuously clone and aswell use names for a furnace
should i still change that to instances?

hollow citrus
jolly obsidian
#

dont use names for indexes

#

am so lost

hollow citrus
jolly obsidian
#

i dont get it

hollow citrus
# jolly obsidian i dont get it

:

what i have been doing to note if each cube was a specific type of cube was the name of it: "blue cube" or "green cube"
i clone each cube multiple times so that the players can continuously be able to make fusions

thought using names was a better idea due to the fact multiple cubes would be the same type

#

im pretty bad at explaining things though

vocal slate
#

U mean base stats?

#

Dunno

#

Personally i think that @jolly obsidian suggestion is alright

#

If u keep track of all cubes on a plane it will be a lot easier to operate on them

#

For example to detect if both cubes are touched, or maybe in range

#

To delete certain one

#

U can make your dictionary kinda clean

#

Local Cubes = {
     ["Blue"] = {...},
     ["Red"] = {...}
}

With that u can find one by their names. And also remember to keep index as an instance

#

Why to keep index as instance tho? Cuz u were confused

#

Imagine two cubes touch eachother, how u will find which one touched? Or which one with? U can take those ones who touched and simply take instance from it in a workspace

local TouchedCube = Cubes[touched]
worn moss
#

wait what

#

cant you just use for loops

#

with tables

hollow citrus
#

Just now getting home

vocal slate
vocal slate
hollow citrus
vocal slate
#

U can make it in different way

#

Every cube can hold a value that indicates their fusion multiplication

#

For example if we merge cubes with 2, so its indicator will be 4 obiviously. And for each multiplication u can apply some effects or boosts

#

Its my idea atleast

#

If u want to go with names then keep it in dictionary

hollow citrus
green torrentBOT
#

studio** You are now Level 2! **studio

vocal slate
#

My bad

hollow citrus
#

yeah

vocal slate
hollow citrus
#

nah thats really my bad...

#

didnt give enough info

vocal slate
#

I don't really know on what principles those games work

#

U must explain

hollow citrus
#

the sky spawns cube types

green red blue white

dirt rock ice

You have tools aswell, a furnace, a researcher, and a dictionary

you try to mix dirt with white cube, nothing will happen

you smelt dirt in a furnace, dirt will become an iron bar or gold bar

mix iron bar with white cube you get iron cube

but

you can also mix iron bar with a red cube to create a throwable cube

vocal slate
#

Ohh, so keep every fusions or craftings in a modules like a data to return

return {


}
hollow citrus
vocal slate
#

Wdym in a tag using their instance

#

😭

#

Oh u meant in a dictionary that holds every cube, am i correct?

hollow citrus
#

i think

vocal slate
#

You refer tag as a index

hollow citrus
#

ya cus i was planning on using the collection service since i recently re-learnt about it

#

does it like not work for this typa thing?

vocal slate
#

It works for every instance

#

In a workspace ofc

#

Well

#

I have to ask

#

When you fuze items, do they lay on the ground?

vocal slate
#

So as i suggested you can put every one of them in a dictionary

#

Easier to track one of them

hollow citrus
#

Ok