What do you want to achieve? I want to make a skilltree system, when the player clicks a textbutton, it appears a skilltree of the character that shows everything to upgrade the character.
What is the issue? The issue is: I know how to do that, although, I can’t figure out a way to avoid conditions just like “if” and “else”, I need to make just one skilltree GUI, so I don’t need to make that to every character on the game. I want to make it so I don’t necessarily need to write something like that:
if Character.Name == (CharacterSkillTree).Name then --Example
--Appear Gui Of The Character
elseif AnotherCharacter.Name == (AnotherCharacterSkillTree).Name then
--Appear Another Gui Of The Character
--And stuff..
What solutions have you tried so far?Every solution.
The point is: How can I do something so I do not overuse “If” and don’t use each gui to each character?
That’s not what I meant. Firstly, the Character is not the player, is a character on the game. I am making a Undertale game that you can upgrade characters, this character is the one you will upgrade, I just don’t want to make each SkillTree to each character, I need to make that so the game will “create” a skill tree based to the character skilltree, I don’t want to use If statement to see if the character name is that so he will create that.
Yea but I don’t want to make each skilltree to each character.
Like:
local SansSkill = game:GetService("StarterGui").SansSkillTree
local SansSkill2 = game:GetService("StarterGui").SansSkillTree2
local SansSkill3 = game:GetService("StarterGui").SansSkillTree3
if (CharacterThatHasBeenChooseToUpgrade) == SansSkill then
--Active skill
elseif (CharacterThatHasBeenChooseToUpgrade) == SansSkill2 then
--...
Look, I need to make a skilltree system. I know how to do that, but I do not want to make multiple skilltree Guis to each character on the game.
Like, I have three characters on my game, I opened the first character stats, that there is a SkillTree textbutton that you can click on it and then it will appear a skilltree GUI Based on the Character Choosen. I want to make that so it opens the skilltree without a Statement and it creates a new skilltree GUI with the informations given.
But I don’t want to make Three skill Trees for Three characters.
You want a UI for every character but slightly different, correct? Use a loop to run through all the characters to create the UI and then inside the function (that the loop runs) use parameters to customize the UI.
local CreateUI = function(Color, Size, Name, TheParent) --These Parameters Can Be Changed To Whatever
local NewFrame = Instance.new('Frame')
NewFrame.BackgroundColor3 = Color
NewFrame.Name = Name
NewFrame.Parent = TheParent
end
local LoopingPlayers = game:GetService('Players'):GetPlayers() --Change This, I'm not sure where you are wanting to loop from
for __, Player in pairs(LoopingPlayers) do
CreateUI(Color3.new(1, 1, 1), UDim2.fromScale(1, 1), 'Frame1', Player.PlayerGui)
end
I made this code server-sided btw, but the entire code can be configured
i recommended making 3 seperate Guis and naming them differently. Then put them in ReplicatedStorage. Now check for CharacterAdded event and clone the respective GUI for your character into PlayerGui
Guys uh, I am not messing up with players. I am messing up with the game’s character, just like sans, chara, frisk, it is characters from Undertale game.
Reference my base code, keep in mind we are helping you, not creating a entire game for you. Please be more descriptive in one message and not slowly giving us more details. That creates a inconvenience and a undefined understanding within the conversation for all of us.
Try using a folder for each character with the possible skills (values with the name of the skill and attributes for points, position, and link (previous skill you need to get it)) on the skill tree. When the skill tree is opened use an if statement to check what character the player is using (id use profileservice for saving data, completely unrelated but whatever man im giving u good advice,)
it would look something like
if plr.EquippedCharacter then
local equippedCharacter = ReplicatedStorage.Characters[plr.EquippedCharacter]
if equippedCharacter then
for i, skill in pairs(equippedCharacter.Skills:GetChildren()) do
--clone gui ish logic
-- when the button is pressed/ player tries to get skill check if they own the last skill needed
if plr.Skills[skill.Link] then
-- fire the server and do checks there or do whatever you want to do
end
end
end
end
after checking their character, loop through every skill in the character folder, then simply clone every node and set it’s attributes, such as it’s position on the skill tree, link, etc
whenever someone is buying a skill, sanity check to make sure they have the correct character equipped,
oh yeah this is probably EXTREMELY unoptimal, im just giving you a base concept on how to achieve what you want dont accept advice from me im not a professional
ALTERNATIVE METHODS
Use super complex table stuffs
make a main module for handling characters and stuff, probably will require object-oriented programming or complex table stuffs
use hacky solutions relying on saved data (don’t do this lol)