#I need help with my GUI my script doesnt work but I am sure it does

1 messages · Page 1 of 1 (latest)

limber canopy
#

I made a script so what a button being pressed shows a description of a class the player can choose. It doesnt work now for some reason and I dont know why

haughty skiff
narrow viper
#

this is some of the worst scripting ive ever seen

#

deadass

haughty skiff
#

We’ve all been there

nova mountainBOT
#

studio** You are now Level 2! **studio

limber canopy
#

Wdym

#

I’ve never made a game before

#

Nor do I even know how to script

#

For a fucking beginner I’m doing better than most people

#

Piss odd

#

Off

limber canopy
#

And also there are 27 variables in total I only coded 7

#

@haughty skiff

haughty skiff
#

You need to learn basic programming. The time it will take you to learn it will be way less that the time it will take you to fix your code later and program, trust me

haughty skiff
#

Want me to explain?

limber canopy
#

Hmmmm

#

Okay

#

My goal is 2 things

#

I want to first get a class selection GUI where the player clicks on class types, the classes in each type and then the class descriptions

#

Secondly, each class description will have a animation of the player weilding their starter weapon

#

@haughty skiff would you mind explaining loops to me

haughty skiff
#

Yeah dw

#

Like I said here:

A loop is just a structure in code which causes a block of code to repeat itself until a condition is met.

There are essentially 4 types of loops:

while loops:
Structure:
‘’’
while condition do
—Inside code
end
‘’’
If the condition between while and do is true, it executes the code inside
until this condition isn’t met, you’ll typically see it used with true or wait() like this:

while wait() do
— This code repeats forever every few milliseconds
end

(Keep in mind wait() yields the execution and then returns true when it ends waiting, hence why it works)

limber canopy
#

so

haughty skiff
#

repeat
— repeated code
until condition

Most rare kind of loop. It’s the same as a while loop except the inner code executes once no matter if the condition is met or not

haughty skiff
limber canopy
#

I am actually so confused

#

I think for now would you mind explaining just the loop that best fits my scenario?

haughty skiff
#

A for loop

#

Specifically a for i,v loop

#

Want me to explain or do you want just the code?

limber canopy
#

well explaining helps me learn right

#

plus im doing this as a long term project so I would like an explanation

haughty skiff
#

Alr

#

Before that rq

#

We will need to use :getchildren(), do you know what it does?

nova mountainBOT
#

studio** You are now Level 3! **studio

limber canopy
#

No

haughty skiff
#

When you do something:GetChildren() it returns a list of all objects inside that something

#

So for example, if I did script.Parent:GetChildren() I would have a list of all the class buttons and the script, because they all have the same parent

limber canopy
#

wait

haughty skiff
#

That helps me a lot, thanks

limber canopy
#

This is my GUI's for now

#

so look

haughty skiff
#

Right

limber canopy
#

the General Class UI is what shows this

haughty skiff
#

I see

#

So you press melee and all melee classes should appear

limber canopy
#

Yess

#

which they do

haughty skiff
#

Okay

#

Now you need the description

limber canopy
#

now in each class

#

is this

haughty skiff
#

👍

limber canopy
#

so then the class description pops up

haughty skiff
#

Noted

limber canopy
#

and finally the end button lets them select the class

#

that part i still have to code

haughty skiff
#

Alr

#

Lemme just give you a quick code fix and you tell me if it works

#

Then if you want I will explain it to you

limber canopy
#

Okay

#

And wait

#

this is the script I was given by someone to let each Main class

#

( Melee, Ranged, Spellcaster, Support, Tactician )

haughty skiff
#

Yeah

limber canopy
#

and in which when they get pressed the subclasses come up

#

i basically copied this to do the same thing for the discriptions

#

but those dont work and only the classes themselves work

#

not their descriptions only the list of them

#

So could you optimize this as well or no?

haughty skiff
#

I think I could do both the class types and classes in one script alone and it would be shorter than all of the scripts you sent

limber canopy
#

wait really?

#

ill need to learn that then

haughty skiff
#

Alr

#

So first of all

haughty skiff
#

Like where is it located in the Gui

limber canopy
haughty skiff
#

Just it’s parent name and type should be enough I think no need to send ss

limber canopy
#

ive selected the code

haughty skiff
#

Yeah

limber canopy
#

that LocalScript is this one

haughty skiff
#

Try placing that same script inside the “melee subclass” frame

#

And lmk how it does

#

And output errors if they exist

limber canopy
#

trying it rn

haughty skiff
#

Aight

limber canopy
#

how do I turn on output errors

haughty skiff
#

Go to view

limber canopy
#

mhm

haughty skiff
#

And there should be a small button to the left on which if you hover it says output

limber canopy
#

okay

haughty skiff
#

It should open a “terminal thingy” on the bottom

limber canopy
#

it did that

haughty skiff
#

Alr

#

If an error occurs, it’ll display there in red

limber canopy
#

okay

haughty skiff
#

Try playing with the script position changed and see how it does

limber canopy
#

so far only this

#

mb

haughty skiff
#

That’s okay, it’s not bc of this script

limber canopy
#

also, doesnt work and no other output errors

peak jackal
#

simple

haughty skiff
#

Alr lemme code something rq

limber canopy
#

i dontt know how to do that

#

im a beginner

haughty skiff
#

I’m making a script brb

#

Place a local script inside General Class GUI and paste this in:

for i,classType in pairs(script.Parent:Get Children()) do
if not v:IsA(“TextButton”) then
break
end
for i,class in pairs(classType:FindFirstChildOfClass(“Frame”):GetChildrrn()) do
class.MouseButton1Click:Connect(function()
for i,class2 in pairs(classType:FindFirstChildOfClass(“Frame”):GetChildrrn()) do
class2.Visible=false
end
class,Visible=true
end)
end
end

nova mountainBOT
#

studio** You are now Level 4! **studio

haughty skiff
#

Sorry had to edit

#

Paste this version now

#

Keep in mind I’m on mobile and have to script in vertical so it’s a pain in the ass for me and so errors may occur

#

If there are output errors lmk

limber canopy
#

oKAY

#

LIKE THIS?

#

mb caps

haughty skiff
#

Yeah but no space between Get and Children at the top

limber canopy
#

i corrected the children mistypes btw

haughty skiff
#

Thanks

limber canopy
#

this is the final thing

haughty skiff
#

Also change v by classType on the top

limber canopy
#

lemme test it

#

v for clas type?

haughty skiff
#

v for classType

#

Also

limber canopy
#

wait im confused

haughty skiff
#

class.Visible instead of class,Visible

haughty skiff
limber canopy
#

so what should I fix

#

like im confused on that

haughty skiff
#

You should replace v in the second line with classType

limber canopy
#

oh ok

nova mountainBOT
#

studio** You are now Level 8! **studio

limber canopy
#

im testing rn

haughty skiff
#

dot instead of comma in that line

limber canopy
#

doesnt work

#

i did that

haughty skiff
#

Any output error?

limber canopy
#

couldnt see

#

lemme retry

haughty skiff
#

Okay

limber canopy
haughty skiff
#

Oh yeah

#

That explains a lot

#

So 1: change break by continue

limber canopy
#

ok

haughty skiff
#

Then rewrite every using your own keyword’s quotation marks (Apparently my phone’s quotation marks aren’t actual quotation marks)

#

If your code has no underlines that is a good sign

limber canopy
#

ok

#

one sec

#

testing rn

#

well

#

didnt work and this came up

haughty skiff
#

Can you send the code screenshot rq?

limber canopy
#

ok

haughty skiff
#

There’s a double double quotation after TextButton

#

It should be just one double quotation

limber canopy
#

ok

haughty skiff
#

I think that should be it for now

limber canopy
#

okay

#

so it sorta works

#

the description doesnt come up

#

and all the other classes dissapear except for melee where the whole thign dissapears

haughty skiff
#

: o

#

Lemme check rq

#

Let’s fix the description rirst

haughty skiff
#

Replace all that orange stuff by the following

limber canopy
#

okay

#

so beyond class.MouseButton1Click:Connect(function()

haughty skiff
#

Yeah, except the two ends at the bottom

nova mountainBOT
#

studio** You are now Level 5! **studio

haughty skiff
#

Right where you deleted that code, replace it with this one:

for i,class2 in pairs(classType:FindFirstChildOfClass("Frame"):GetChildren()) do

class2:FindFirstChildOfClass("Frame").Visible = false
end
class:FindFirstChildOfClass("Frame").Visible = true

limber canopy
#

ok

haughty skiff
#

Lmk if there is any underlining, output errors or malfunctions

limber canopy
#

is this good?

haughty skiff
#

I believe so yeah

#

Go try it and lmk how you do

limber canopy
#

doesnt work

haughty skiff
#

Are there any other errors?

limber canopy
#

no

#

is the blue on the left where the code started from?

haughty skiff
#

Like the for keywords?

haughty skiff
#

Alr it’s 1:30 am for me here, it’s getting late so I’m going to sleep

#

Tomorrow I get on my PC and I’ll fix u this

#

Add me to dms if u want

limber canopy
#

okay

#

sure

haughty skiff
#

@limber canopy I fixed it

#

Put a local script inside General Class GUI and paste this in:

for i,classType in pairs(script.Parent:GetChildren()) do
    if not classType:IsA("TextButton") then
        continue
    end
    classType.MouseButton1Click:Connect(function()
        for i,classType2 in pairs(script.Parent:GetChildren()) do
            if not classType2:IsA("TextButton") then
                continue
            end
            classType2:FindFirstChildOfClass("Frame").Visible = false
        end
        classType:FindFirstChildOfClass("Frame").Visible = true
    end)
    for i, class in pairs(classType:FindFirstChildOfClass("Frame"):GetChildren()) do
        if not class:IsA("TextButton") then
            continue
        end
        class.MouseButton1Click:Connect(function()
            for i, class2 in pairs(classType:FindFirstChildOfClass("Frame"):GetChildren()) do
                if not class2:IsA("TextButton") then
                    continue
                end
                class2:FindFirstChildOfClass("Frame").Visible = false
            end
            class:FindFirstChildOfClass("Frame").Visible = true
        end)
    end
end
#

Here’s how it should act

#

Every class and subclass button works automatically (It doesn’t matter if you add a new button or if you change class names, it will still work)

#

All in just that script

limber canopy
#

Wait

#

Fr?

haughty skiff
#

yeah

limber canopy
#

hmmm

#

i jus got back from going out ill need to learn how to use this

#

@haughty skiff whenever you have some free time mind sending me a tutorial or a series I can watch to learn about coding?

#

particularly one about open world games or my type of game

#

but im not picky

#

just one you reccomend

haughty skiff
#

@limber canopy You should learn the basics of coding first and only then should you go to more specific niches like open world games

#

Use this yt playlist to learn easily in some hours

#

keep in mind it takes practice to fully learn to a good point and it’s expected to make tons of annoying mistakes along the way so don’t give up

#

Did the script work btw?

limber canopy
#

okay

limber canopy
#

it worked great