#OOP (please explain me how the hell i need to make the "SELF" manager for every players, because i d

1 messages · Page 1 of 1 (latest)

glad verge
#

So basically I was working on the game, and as everybody i am using modules. BUT! Here's thing: my game uses a lot of different techniques, and i decided to make a separate local script for every single one. So in general i have like 5 local scripts and some server scripts, and they structurize the code. BUT! I somehow need to get the SELF for players which would be synchronized with each other. And i got no clue how to do it properly.

So i tried to make a module that would be making like "new characters" (basically Module.new(player)) if the SELF for player is not existing. If it does, it returns the SELF for the player which is stored inside of the table in module script.

I thought it will work but nope.

Every time i try to launch the scripts, it just says like "attempt to index nil with FindFirstChild() etc (basically Character is not being found in the SELF for player, even though Module script creating a self for player which includes the character.

My system is somehow broken and the problem with SELFs is the one problem that stops me from making game.

Here's all of the code parts that get the SELF for player for everything to work.

If you have another idea how to manage this garbage, dm me or write here your idea. Thanks.

#

and if you have some tips about this or tips about oop then feel free to share

vocal sequoia
#

like in the screenshots its underlines which caused me to induce that you probably used the wrong index for findfirstchild

#

as for how you can build ontop of character by adding self, well you could have a character object, which has different components like weapon welding manager or something

#

you should look into OOP and ECS in general, and actually understand those concepts

#

they'll help you a ton

glad verge
#

well.. I'll try to look at concepts, but..

How the hell am i using wrong index for findfirstchild?

Like lemme send a piece of code

#

in this case i use pure methods instead of functions

#

sooo

#

idk what you talk about like "wrong index"

#

I don't think that it's wrong index it's just somehow arguing pieces of code...

#

Should i put everything together or what to-doo....

sand quiver
#

I mean if u can't u don't need to use module scripts for almost everything

#

Especially if it's ur 1st, 2nd game

glad verge
#

But everybody says that I am supposed to

nimble zenithBOT
#

studio** You are now Level 3! **studio

glad verge
#

because when i hop to modules i suddenly realized how shit my code was looking like when i decided to make my first game

#

Modules just help me to structurize the code for it not to smell lol

#

That's why i ask how...

How to make that self manager..

vocal sequoia
#

see what it say

#

the one with the red line underneath it

#

it should show the error

glad verge
#

nah it's not the problem in the module itself

#

the module is fine

#

i think it's just a conflict of calling selfs

#

and somehow it end up with no character inside self (or it is just another self)

vocal sequoia
#

Like I think you're thinkin about this in the wrong way

#

OOP should help you build more features ontop of the already made roblox

#

should help you innovate

#

if you want to data to be available to both the client and the server, use methods like value objects or attributes

#

anyways

nimble zenithBOT
#

studio** You are now Level 16! **studio

vocal sequoia
#

there is literally a red line under

#

it should show the error

glad verge
#

I can even explain why there is an error

#

So basically look at my NewCharacter() function. It takes two parameters, one is not necessary (there is a check for that, if it's nil then it's defaultcharacter)

#

and system just think that i'm dumb that didn't put it inside

#

basically, that function runs very well

#

I think you shouldn't look at that one cuz that function works well as if i call it with or without the second parameter

vocal sequoia
#

ok

#

Ik what the problem is

#

check if nil like this instead

#
if not GameCharacter then
--//Code
end
#

@glad verge

glad verge
#

???

#

how would that help it