#Question regarding the managing of entities

1 messages · Page 1 of 1 (latest)

glad stratus
#

Hi y'all. Im still very much new to Roblox Studios and working my way up with Luau. But one thing that got my attention was the way scripts work. As to my knowledge all scripts get called at the start of the game and do certain things etc.

But how could you use entities? As to my knowledge I would have to store their model and logic somewhere in the world and replicate them when they need to spawn. But how would I go about making their logic only run when spawned and not when they just exist outside of the play area, waiting to be duplicated and spawnd. (Let me know if this is the wrong idea of managin entity models).

That is part one of my question. Part two is "How can you efficiently make scripts comminicate with one another?" I heard about module scripts as a form of "global" script that anyone can call toward. But I dont know if thats the way to go. Like lets say I want a script in a bear comminicate with a script in a tree and make that tree fall down or smth.

And for the last part of my question; "When to use what script and where?"
As far as I know you have normal scripts, module scripts, scripts in the server( serverscript holding thingy ), client scripts( clientscript holding thingy ) and possible more?
But when should I make a script inside the server hold and when in the client? What's the use of normal scripts( the grey ones ) as I could also run them in the server or client hold?

Sorry for all these questions but this is my major confusion from switching from Godot to Roblox Studios. The way scripts comm and where they are stored are just way diff from the Godot engine. And making like three diff posts for this in here seems like overkill.

I am so thankfull for everyone who will try and explain this to my 😂 🙏

ivory plover
# glad stratus Hi y'all. Im still very much new to Roblox Studios and working my way up with Lu...

How to use/manage entities: you could opt for one of the following approaches, first is OOP (Object Oriented Programming), you would have a specific entity class that you can instantiate when needed to spawn that entity and give it functionality and destroy it when it's not needed anymore instead of having a script inside each model. Or the other way which is ECS (Entity Component System) which could be a bit complicated to explain here so I recommend searching up what ECS is to get better understanding of how it works, both have their pros and cons and there are many other ways to handle entities but these are just the two I usually use, as for when to use different kinds of scripts and how to organize them I would say you learn that as time goes by and as you gain more experience, scripts usually handle server sided stuff which need to be replicated to all players, players have no control over server code (unless you give them access to) so it's more secure for handling critical things like purchases, some game logic and to avoid having the player exploiting and manipulating things to gain unfair advantage, local scripts on the other hand run on the client's machine so they have control over them, that's why usually you only handle some things on it like user interface (only seen by the player on his screen) and inputs, and other things, to communicate between the server and client you use remote events/functions, which are used to send data between the client and server, as for module scripts they are usually used for things that are needed by multiple scripts or usually used to split up code for organization and productivity purposes, module scripts return a value which can be accessed by any script that requires it whether it's a script or a local script

#

I would recommend checking the api docs to understand some things better

glad stratus
ivory plover
#

have you used unreal engine or unity before ?

glad stratus
#

I have a question, would you be willing to explain more about OOP? As what I am doing atm does not include any fancy AI or complicated logic(im far too early in Luau for that imo) so trying to understand ECS this early would be overkill

glad stratus
#

I have experience with Python and Godot 😄

ivory plover
ivory plover
glad stratus
#

Like what does it mean

glad stratus
ivory plover
glad stratus
#

Thats neat

#

but not really what I need to focus on atm. Like u said 😅
No point in using api if you can't connect any logic to the interfaces haha

ivory plover
glad stratus
ivory plover
#

which takes a vector3 or a part and attempts to move the character to it

worn cliffBOT
#

studio** You are now Level 12! **studio

glad stratus
#

What is the best position to place/store this model and the logic?( Explorerwise as in what folder or smth? )

ivory plover
#

assets that need to be accessed by both the server and client could be placed in ReplicatedStorage, assets that only need to be accessed by the server could be placed in server storage

glad stratus
#

while it would go in replicated storage if he does need to or can manipulate it?

ivory plover
#

well he can change things only if you are doing sanity checks on the client and trusting those checks on the server, if the server does it's own checks and never trusts the client then the client can't do anything even if you give them the model

glad stratus
#

wdym "trusts" the client? 😅

#

Does having cartain things in certain storages restrict clients from even being able to use them?

#

(Would be very cool)

ivory plover
ivory plover
glad stratus
#

Oh one thing tho

#

When I put a model in replicatedstorage, why did it go invisible?

ivory plover
#

only models in workspace are rendered

glad stratus
#

oooh

#

is there a way to make them render in storage, so you can kinda see whatever you all store there 😅

ivory plover
#

you put instances in other places to store them and clone them or move them when needed

glad stratus
#

Then why would you place things in a storage like that? It would be hard to adjust the models and all, no?

#

Or do people just take them out of storage, alter them, then put it back?

ivory plover
#

nope, you just store the model there and when needed you would clone it and put it in workspace

glad stratus
#

So when I need the model during runtime I clone it and then put in workspace, no?

#

(Clone it via accessing the storage)

#

And what if I need one of them to be there from the very start, do I just put them inside of workspace already while keeping one in storage for during runtime?

ivory plover
glad stratus
#

Makes sense

#

As I assume after parenting it it would be at (0,0,0)

worn cliffBOT
#

studio** You are now Level 6! **studio

ivory plover
glad stratus
#

but I would change the position anyways, right?

#

Cuz it will probably need to be elsewhere

glad stratus
#

it totally depends on where I need that model

glad stratus
#

@ivory plover

ivory plover
ivory plover
#

you could have some kind of indicators to where the models should spawn and just spawn them when the game starts

ivory plover
glad stratus
#

Oh and another question 😅
I got like a dozen or so models in my project atm inside of workspace, they make up the map atm, but would it be good sport to have like a folder in there called "world" and inside of there "trees", "rocks", etc. To organize them?

ivory plover
ivory plover
#

organization helps in the long run when things get big and there are a lot of assets

glad stratus
#

Im still kind off struggling to understand what all the pregiven things are for in the explorer

#

Like replicatedstorage

#

serverstorage

#

serverscriptservice

#

But I think I might understand them

ivory plover
glad stratus
#

So the replicatedstorage are for models that anyone can acces
serverstorage for server only acces
serverscriptservice for scripts that run on the whole server, so anyone can see the changes etc
and starterplaterscripts are logic for client-only. Like showing certain models that only he can see or UI

Is this correct? kinda

ivory plover
glad stratus
ivory plover
glad stratus
glad stratus