How can i make a Skill tree?

I found a tutorial, check it out and see if it works for you

Otherwise, one way you can utilize an object-oriented programming structure(OOP) for a skill structure as this post suggests.

I prefer using @Kironte OOP template which you can structure a skill object like this:

-- Initialize Object Class
local Package = script:FindFirstAncestorOfClass("Folder")
local Object = require(Package.BaseRedirect)

local Skill = Object.new("Skill")

function Skill.new(Name,UnlockCost,Requirements)
	local obj = Skill:make()
    
    --Create a table to store what previous skill objects are required
    obj.Requirements = Requirements

    obj.UnlockCost = UnlockCost

    obj.Name = Name

    obj.IsUnlocked = false

	return obj
end

--Function for a skill object
--Checks through the objects within the Skill's Requirement table unlocked property
--If a single skill is not unlocked yet then the check fails
function Skill:CheckRequirementsAndUnlock()

    local allPreviousSkillsUnlocked = true

    for _ , PreviousSkillsRequired in pairs(self.Requirements) do

        if not PreviousSkillsRequired.IsUnlocked then
            allPreviousSkillsUnlocked = false
        end

    end

    if allPreviousSkillsUnlocked then

        --Do stuff now that it has been confirmed that the
-- previous skills are all unlocked

    end

end
return Skill

Overall, the question is pretty abstract and there are plenty of better ways to do a skill system it’s best to plan it out first what a skill object needs one by one like so:

Skill object will need:

  1. Prerequisite skills what skills you will need before unlocking this one

  2. Unlock conditions/costs

  3. Method to tell GUI that the skill is unlocked and change GUI as so

  4. Method to give the player the actual ability/stats bonus

And then you can spice it up by working with skill inheritance so you can make different types of skills like:

  1. Passive stats skill just gives flat out stat bonuses

  2. Active skills that handle the player actions in the world.

fundamentally skills trees are just an extensive boolean check. I don’t think I explained well so please ask me more questions on whatever I just wrote.

6 Likes