How do you make a Character Selection..?

Okay! -------------------------

1 Like

If you still want the problem to be solved in the original game, just paste all the scripts that are causing the error here. But downloading that place file should save you that hassle.

1 Like

Oh my god I did everything wrong I’m so sorry for the inconvienence. I placed another script in the modulescript. Thank you!

1 Like

No no you’re fine! Make mistakes, just remember to learn from 'em! Hope my solution fit all your needs.

1 Like

Can I add more characters though?

1 Like

Yea, that’s why I made it a Class system. All you need to do is look at what I did in the module script. You simply just add more to the ‘RealCharacters’ module like so:
image

1 Like

And you can add as many properties as you like to each class like I demonstrated before; like health, speed, etc. Just remember to properly reference the items you load into the Backpack table within the class.

1 Like

I copied everything from your game to my game, But I keep getting this error?

  20:44:26.303  ServerScriptService.Main:15: attempt to index nil with 'LoadCharacterAsSelf'  -  Server - 1:15
  20:44:26.303  Stack Begin  -  Studio
  20:44:26.303  Script 'ServerScriptService.1', Line 15  -  Studio - 1:15
  20:44:26.303  Stack End  -  Studio
1 Like

The reason you are getting that error is because inside of the “CharacterAdded” function I had wrapped within the “PlayerAdded” function was referencing a non-existent variable I forgot to assign to.

1 Like

I’m pretty sure I gave you the script that fixed it, but if you’re still getting an error for it then it must be something unrelated which is odd.

1 Like

I copied every script from your game that you gave me, It work’s on your game but not on mine?

1 Like

Hmm… I know I sound like a broken record but could you please share all the scripts you’ve made from what I gave you in this post: RealCharacters, the player script, the remote event script, etc…

1 Like

And maybe a screenshot of where you’re putting the scripts?

1 Like

Oh I just edited a thing now it’s working!, Player:SetAttribute(‘SelectedCharacter’, ‘Sword’, ‘Hyperlazer’)

It was Player:SetAttribute(‘SelectedCharacter’, ‘Example1’') Only!

1 Like

The problem is character selection isn’t working but, Only the sword is working.

1 Like

Like the sword is the only character.

1 Like

Oh! You’re confused about attributes! Attributes only take two arguments, one is the name of the attribute and the second argument is the value itself.

In this case, I made a string value called “SelectedCharacter” that is tied to the Player; and the value disposed inside the attribute is the name of the character you are playing as.

When the player is loaded into the game, the script detecting the character getting added will check what value is held in this attribute A.K.A checking what character the player has selected.

After this check, the script validates if the character can be found in a table, with this table being “RealCharacters”. If it is found, the name acts as a sort of key in unlocking the character data for the player to load as. I recommend looking into learning more about tables because they are really powerful.

But other than that don’t rely on others for giving you complete project mechanics. I suggest you use my system as a stepping stone to learn from and to look more into certain things I implement to make sure you can actually read the code and apply it to other aspects of your game.

1 Like

By the character selection you mean pressing the button to switch characters?

1 Like

Yeah Like this one:
image

Ok so did you keep the name “Example1” and all that? Cause that was just an example, you can change the name of it to what you want to character to be actually named: like “Sword”.

Secondly, did you put the hyperlaser in the backpack of the class that’s supposed to have the hyperlaser?

Example:
image