I’m currently working on making a GUI, which has different skills you can obtain depending on what sort of class you’re under.
Currently, I have premade different skill trees which are duplicated and then displayed, according to the players class, however, I am having issues with button interactions within this specific menu.
There are two menus, one with base skills you can unlock, and the other being the specific class skills.
The base skill tree works without issue, however the specific class skill buttons do not work at all.
Now, all the elements in the GUI, and therefore button interactions, all work through individual scripts which each handles different things, such as displaying the skills information, changing the interface, closing the menu and so on. Therefore, all of the GUI elements should interact in the same way.
The only thing that is different is that the class skill tree is a duplicated version as to make it easier to handle updating which skills have been unlocked, and avoid likewise named skills that are not apart of the specific class of the player.
To combat any issues with the directory being wrong or any mixups happening that I can’t view, I’ve moved the specific class overlays to the ReplicatedStorage, to then be copied in, as well as put in a fail-safe within the script that handles the buttons to only allow interactions once there has been an update to the GUI.
I’ve tried to determine whether or not it’s a directory issue within the script, and everything seems fine on that part.
I also made sure to double check ZIndexes, which buttons/frames are active and interactable etc. None of those are an issue as far as I’m aware.
I’ve also tried to yield a lot of areas in the script to try see if that helped, and nothing.
Currently, this is the script that handles the buttons:
local player = game.Players.LocalPlayer
local Menu = player.PlayerGui:WaitForChild("SkillTree")
local UILayout = Menu.Base.Main.Skills.UIPageLayout
function DisplayAbility(Button)
local SkillDisplay = Menu.Base.MainSkillDisplay
local info = Button.Info.Value
local title = Button.Title.Value
local image = Button.Background.Image
local cost = Button:GetAttribute("SkillCost")
local Key = Button:GetAttribute("Key")
local Prerequisite = Button:GetAttribute("Prerequisite")
local attained = Button:GetAttribute("SkillAttained")
-- Initial setup
SkillDisplay.Underlay.SkillImage = image
SkillDisplay.Underlay.CostValue.Text = cost
SkillDisplay.Underlay.Title.Text = title
SkillDisplay.Underlay.Info = info
SkillDisplay.Underlay.SkillImage:SetAttribute("Lock",Key)
SkillDisplay.Underlay.SkillImage:SetAttribute("Prerequisite",Prerequisite)
SkillDisplay.Visible = true
-- If skill is attained
if attained == true then
SkillDisplay.Underlay.UnlockButton.Text = "Unlocked"
SkillDisplay.Underlay.UnlockButton.BackgroundColor3 = Color3.new(0.305882, 0.356863, 0.356863)
SkillDisplay.Underlay.UnlockButton.TextColor3 = Color3.new(1, 1, 1)
SkillDisplay.Underlay.UnlockButton.Active = false
end
end
function UpdateButtons(ButtonDisplay)
for i,button in ButtonDisplay.Abilities:GetChildren() do
if not button:IsA("ImageButton") then return end
if button:GetAttribute("SkillAttained") == true then
button.Underlay.Visible = true
button.ImageTransparency = 1
print(button.Name.." skill is unlocked")
elseif button:GetAttribute"SkillAttained" == false then
button.Underlay.Visible = false
button.ImageTransparency = 0
print(button.Name.." skill is not unlocked")
end
end
for i,button in (ButtonDisplay:GetDescendants()) do
if button:IsA"ImageButton" then
if button.MouseButton1Click:Connect(function()
print"Connected" -- This does not print on the class overlay, but prints on the main player overlay
end) then
end
end
end
end
UILayout.Changed:Connect(function()
wait()
if UILayout.CurrentPage == Menu.Base.Main.Skills.PlayerOverlay then
local Overlay = Menu.Base.Main.Skills.PlayerOverlay.BasePlayerOverlay
UpdateButtons(Overlay)
warn(Overlay.Name.. " has been updated")
elseif UILayout.CurrentPage == Menu.Base.Main.Skills.ClassOverlay then
local Overlay = Menu.Base.Main.Skills.TitanOverlay:WaitForChild"BranchOverlay"
UpdateButtons(Overlay)
warn(Overlay.Name.. " has been updated")
end
end)
Here is the script that handles changing between the main player overlay and the specific class overlay:
local Menu = game.Players.LocalPlayer.PlayerGui:WaitForChild("SkillTree")
local SkillTree = Menu.Base.Main.Skills
local OverlayButton = Menu.Base.Main.OverlayButton
local UILayout = SkillTree.UIPageLayout
local TweenService = game:GetService("TweenService")
local RS = game:GetService("ReplicatedStorage")
function PivotFrameTween()
local pivotFrame = Menu.PivotFrame
local info = TweenInfo.new(0.35,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,true,0.2)
local PivotFrameTween = TweenService:Create(pivotFrame,info,{Size = UDim2.new(1,0,1,0)})
PivotFrameTween:Play()
end
OverlayButton.MouseButton1Click:Connect(function()
local class = game.Players.LocalPlayer.Backpack:WaitForChild("Class").Value
if class == "None" then return end
PivotFrameTween()
wait(.55)
if UILayout.CurrentPage == SkillTree.PlayerOverlay then
UILayout:JumpTo(SkillTree.ClassOverlay)
OverlayButton.Image = OverlayButton:GetAttribute(Class.."Img")
OverlayButton.HoverImage = "rbxassetid://17884309159"
if not SkillTree.ClassOverlay:FindFirstChild("BranchOverlay") or SkillTree.ClassOverlay.BranchOverlay:GetAttribute("Class") ~= class then
for i,overlay in RS.OverlayTypes:GetDescendants() do
if overlay:GetAttribute("Class") == class then
local SpecificOverlay = overlay:Clone()
if SkillTree.ClassOverlay:FindFirstChild("BranchOverlay") then
SkillTree.ClassOverlay:FindFirstChild("BranchOverlay"):Destroy()
else
SpecificOverlay.Parent = SkillTree.ClassOverlay
SpecificOverlay.Active = true
SpecificOverlay.Visible = true
end
end
end
end
else
UILayout:JumpTo(SkillTree.PlayerOverlay)
OverlayButton.HoverImage = "rbxassetid://17884563427"
OverlayButton.Image = "rbxassetid://17884309159"
end
end)
Here is the directory within the skills menu:
This entire issue has put everything regarding unlocking skills/the player GUI on pause and I’m genuinely lost at what the issue could be.
Is it worth rewriting the code to handle updating the buttons/skills for each specific class differently or is there a solution that’s going over my head that I just can’t see?
Any help would be appreciated!
Thank you.