0% found this document useful (0 votes)
5 views7 pages

GUI Button Setup for Game Scripts

The document is a Lua script for a game interface that manages player interactions with skill buttons, menu buttons, and shop items. It includes functions for setting up button behaviors, handling clicks, and updating the GUI based on player actions. The script also manages the visibility of various elements and ensures that player inputs are processed correctly while preventing multiple simultaneous actions.

Uploaded by

dubazz4ikkr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

GUI Button Setup for Game Scripts

The document is a Lua script for a game interface that manages player interactions with skill buttons, menu buttons, and shop items. It includes functions for setting up button behaviors, handling clicks, and updating the GUI based on player actions. The script also manages the visibility of various elements and ensures that player inputs are processed correctly while preventing multiple simultaneous actions.

Uploaded by

dubazz4ikkr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

if not script.

Parent:FindFirstChild("Loaded") then
wait(3)
local folder = [Link]("Folder")
[Link] = [Link]
[Link] = "Loaded"
end

wait(0.2)

local localPlayer = [Link]


local serverTraits =
localPlayer:WaitForChild("Backpack"):WaitForChild("ServerTraits")
local selectedButton = nil
local hoveredButton = nil
local canClick = true
local gui = serverTraits:WaitForChild("GUI")

function setupSkillButton(button)
[Link] = false

button.MouseButton1Click:Connect(function()
if canClick then
canClick = false

if button:FindFirstChild("Trans") then
[Link]:Play()
gui:FireServer(button, selectedButton)
wait()
canClick = true
return
end

if selectedButton == nil then


button:FindFirstChild("Selected").Visible = true
[Link]:Play()
selectedButton = button
else
gui:FireServer(button, selectedButton)
selectedButton:FindFirstChild("Selected").Visible = false
if hoveredButton then
hoveredButton:FindFirstChild("Selected").Visible =
false
end
selectedButton = nil
hoveredButton = nil
end

wait()
canClick = true
end
end)

[Link]:Connect(function(input)
if [Link] == [Link]
and selectedButton ~= nil
and button ~= selectedButton
and button ~= hoveredButton then

if hoveredButton ~= nil then


hoveredButton:FindFirstChild("Selected").Visible = false
end
hoveredButton = button
button:FindFirstChild("Selected").Visible = true
end
end)
end

[Link]:Connect(function(descendant)
wait(0.3)
if descendant:FindFirstChild("Selected") then
setupSkillButton(descendant)
end
end)

function setupMenuButton(button)
[Link]:Connect(function(input)
if [Link] == [Link].MouseButton1 or
[Link] == [Link] then
if selectedButton then
selectedButton:FindFirstChild("Selected").Visible = false
end
if hoveredButton then
hoveredButton:FindFirstChild("Selected").Visible = false
end
selectedButton = nil
hoveredButton = nil

if [Link]:FindFirstChild([Link]) then
[Link]:Play()
[Link]:FindFirstChild([Link]).Visible = not
[Link]:FindFirstChild([Link]).Visible

for _, child in pairs([Link]:GetChildren()) do


if child:IsA("ImageLabel") and child ~=
[Link]:FindFirstChild([Link]) and [Link] ~= "Senzu" then
[Link] = false
end
end
end
end
end)

[Link] = 0
local originalColor = button.ImageColor3
button.ImageColor3 = [Link](originalColor.R * 1.2, originalColor.G * 1.2,
originalColor.B * 1.2)
local brightenedColor = button.ImageColor3

[Link]:Connect(function()
button.ImageColor3 = [Link](brightenedColor.R * 0.8,
brightenedColor.G * 0.8, brightenedColor.B * 0.8)
end)

[Link]:Connect(function()
button.ImageColor3 = brightenedColor
end)
end
function setupCategoryButton(button)
button.MouseButton1Click:Connect(function()
if selectedButton then
selectedButton:FindFirstChild("Selected").Visible = false
end
if hoveredButton then
hoveredButton:FindFirstChild("Selected").Visible = false
end
selectedButton = nil
hoveredButton = nil

if [Link]:FindFirstChild([Link] .. "X") then


[Link]:Play()
for _, child in pairs([Link]:GetChildren()) do
if [Link]([Link], "X") then
[Link] = false
end
end
[Link]:FindFirstChild([Link] .. "X").Visible = true
end
end)

local originalColor = button.ImageColor3

[Link]:Connect(function()
button.ImageColor3 = [Link](originalColor.R * 0.8, originalColor.G
* 0.8, originalColor.B * 0.8)
end)

[Link]:Connect(function()
button.ImageColor3 = originalColor
end)
end

for _, hotbarButton in pairs([Link]:GetChildren()) do


if hotbarButton:IsA("ImageButton") then
setupSkillButton(hotbarButton)
end
end

for _, kiButton in
pairs([Link]:WaitForChild("Skills").[Link]:GetChildren())
do
if kiButton:IsA("ImageButton") then
setupSkillButton(kiButton)
end
end

for _, meleeButton in
pairs([Link]:GetChildren()) do
if meleeButton:IsA("ImageButton") then
setupSkillButton(meleeButton)
end
end

for _, transformButton in
pairs([Link]:GetChildren()) do
if transformButton:IsA("ImageButton") then
setupSkillButton(transformButton)
end
end

for _, sideMenuButton in pairs([Link]:GetChildren()) do


if [Link] == "Save" then
local mouse = localPlayer:GetMouse()
[Link]:Connect(function(input)
if [Link] == [Link].MouseButton1 or
[Link] == [Link] then
[Link]:FireServer({"save"}, [Link], input)
end
end)
elseif sideMenuButton:IsA("ImageLabel") or sideMenuButton:IsA("ImageButton")
or sideMenuButton:FindFirstChild("TextLabel") then
setupMenuButton(sideMenuButton)
elseif [Link] == "Mute" then
[Link]:Connect(function(input)
if [Link] == [Link].MouseButton1 or
[Link] == [Link] then
if localPlayer:FindFirstChild("Muted") then
[Link]:Destroy()
else
local muteFolder = [Link]("Folder")
[Link] = "Muted"
[Link] = localPlayer
end
end
end)
end
end

for _, skillCategory in pairs([Link]:GetChildren()) do


if skillCategory:FindFirstChild("TextLabel") then
setupCategoryButton(skillCategory)
end
end

for _, shopCategory in pairs([Link]:GetChildren()) do


if shopCategory:FindFirstChild("TextLabel") then
setupCategoryButton(shopCategory)
end
end

local canBuy = true


[Link]:Connect(function(input)
if [Link] == [Link].MouseButton1 or [Link] ==
[Link] then
if not canBuy then return end
canBuy = false

spawn(function()
local result =
[Link]:InvokeServer([Link]
)
if result == "bought" then
[Link]:Play()
elseif result == "req" or result == "owns" then
[Link]:Play()
[Link] = "Purchase"
else
[Link]:Play()
end
end)

wait(0.4)
canBuy = true
end
end)

function setupBuyButton()
local buyButton = [Link]
local originalColor = buyButton.ImageColor3
buyButton.ImageColor3 = [Link](originalColor.R, originalColor.G,
originalColor.B)
local buttonColor = buyButton.ImageColor3

[Link]:Connect(function()
buyButton.ImageColor3 = [Link](buttonColor.R * 0.8, buttonColor.G *
0.8, buttonColor.B * 0.8)
end)

[Link]:Connect(function()
buyButton.ImageColor3 = buttonColor
end)
end

setupBuyButton()

function setupShopItem(item)
item.MouseButton1Click:Connect(function()
[Link]:Play()
[Link]:WaitForChild("Shop").[Link] =
[Link]
[Link] = [Link]
[Link] = "Level: " ..
[Link] .. ", Zenni: " .. [Link]
end)

[Link]:Connect(function()
[Link] = 0.1
end)

[Link]:Connect(function()
[Link] = 0.5
end)
end

for _, shopKiItem in
pairs([Link]:WaitForChild("Shop").[Link]:GetChildren())
do
if shopKiItem:IsA("ImageButton") then
setupShopItem(shopKiItem)
end
end

for _, shopMeleeItem in
pairs([Link]:GetChildren()) do
if shopMeleeItem:IsA("ImageButton") then
setupShopItem(shopMeleeItem)
end
end

for _, shopTransformItem in
pairs([Link]:GetChildren()) do
if shopTransformItem:IsA("ImageButton") then
setupShopItem(shopTransformItem)
end
end

for _, stat in pairs([Link]:GetChildren()) do


if stat:FindFirstChild("ImageButton") then
[Link].MouseButton1Click:Connect(function()
[Link]:FireServer(stat)
end)
end
end

local skillsLoaded = false


[Link]:Connect(function(child)
if [Link] == "Skills" then
for _, skillCategory in pairs([Link]:GetChildren()) do
if skillCategory:FindFirstChild("TextLabel") then
setupCategoryButton(skillCategory)
end
end

for _, kiSkill in
pairs([Link]:WaitForChild("Skills"):WaitForChild("KiAttacksX").ScrollingFram
e:GetChildren()) do
if kiSkill:IsA("ImageButton") then
setupSkillButton(kiSkill)
end
end

for _, meleeSkill in
pairs([Link]:GetChildren()) do
if meleeSkill:IsA("ImageButton") then
setupSkillButton(meleeSkill)
end
end

for _, transformSkill in
pairs([Link]:GetChildren()) do
if transformSkill:IsA("ImageButton") then
setupSkillButton(transformSkill)
end
end

skillsLoaded = true
end
end)

local characterButtons = {}
characterButtons[#characterButtons + 1] = [Link]
characterButtons[#characterButtons + 1] = [Link].Accessory2
characterButtons[#characterButtons + 1] = [Link]
characterButtons[#characterButtons + 1] = [Link]
for _, characterButton in pairs(characterButtons) do
local originalColor = characterButton.ImageColor3

[Link]:Connect(function()
characterButton.ImageColor3 = [Link](originalColor.R * 0.8,
originalColor.G * 0.8, originalColor.B * 0.8)
if characterButton:FindFirstChild("ImageLabel") then
[Link].ImageColor3 =
[Link](originalColor.R * 0.8, originalColor.G * 0.8, originalColor.B * 0.8)
end
end)

[Link]:Connect(function()
characterButton.ImageColor3 = originalColor
if characterButton:FindFirstChild("ImageLabel") then
[Link].ImageColor3 = originalColor
end
end)

[Link]:Connect(function(input)
if [Link] == [Link].MouseButton1 or
[Link] == [Link] then
[Link]:Play()
[Link]:FireServer(characterButton)
end
end)
end

[Link]:Connect(function(accessory)
accessory.MouseButton1Click:Connect(function()
[Link]:FireServer(accessory)
end)
end)

[Link]:Connect(function()
if [Link] == false then
[Link] = false
end
end)

You might also like