#I need help with my GUI my script doesnt work but I am sure it does
1 messages · Page 1 of 1 (latest)
- Are all buttons’ active property set on?
- I suggest changing Activated to MouseButton1Click if you’re placing the buttons in a screengui
- You should use a loop instead of 7 variables and 7 functions each with 7 statements
We’ve all been there
** You are now Level 2! **
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
I don’t know what a loop is
And also there are 27 variables in total I only coded 7
@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
A loop is just a structure in code which causes a block of code to repeat itself until a condition is met
Want me to explain?
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
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)
so
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
Ye?
I am actually so confused
I think for now would you mind explaining just the loop that best fits my scenario?
A for loop
Specifically a for i,v loop
Want me to explain or do you want just the code?
well explaining helps me learn right
plus im doing this as a long term project so I would like an explanation
Alr
Before that rq
We will need to use :getchildren(), do you know what it does?
** You are now Level 3! **
No
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
That helps me a lot, thanks
Right
so the Melee Subclass here shows all the classes
now in each class
is this
👍
so then the class description pops up
Noted
and finally the end button lets them select the class
that part i still have to code
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
Okay
And wait
this is the script I was given by someone to let each Main class
( Melee, Ranged, Spellcaster, Support, Tactician )
Yeah
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?
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
Can you show me this script on the explorer rq?
Like where is it located in the Gui
Just it’s parent name and type should be enough I think no need to send ss
Yeah
that LocalScript is this one
Try placing that same script inside the “melee subclass” frame
And lmk how it does
And output errors if they exist
trying it rn
Aight
how do I turn on output errors
Go to view
mhm
And there should be a small button to the left on which if you hover it says output
okay
It should open a “terminal thingy” on the bottom
it did that
okay
Try playing with the script position changed and see how it does
That’s okay, it’s not bc of this script
also, doesnt work and no other output errors
just make a script for when a npc touches this part it opens or does a function to that thing
simple
Alr lemme code something rq
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
** You are now Level 4! **
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
Yeah but no space between Get and Children at the top
i corrected the children mistypes btw
Thanks
Also change v by classType on the top
wait im confused
class.Visible instead of class,Visible
Yeah I just messed it up before
You should replace v in the second line with classType
oh ok
** You are now Level 8! **
im testing rn
And don’t forget this
dot instead of comma in that line
Any output error?
Okay
ok
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
Can you send the code screenshot rq?
There’s a double double quotation after TextButton
It should be just one double quotation
ok
I think that should be it for now
okay
so it sorta works
the description doesnt come up
and all the other classes dissapear except for melee where the whole thign dissapears
Responding to this so I can look it up easily
Replace all that orange stuff by the following
Yeah, except the two ends at the bottom
** You are now Level 5! **
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
ok
Lmk if there is any underlining, output errors or malfunctions
What do you mean?
Like the for keywords?
Or this?
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 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
yeah
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
@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?
okay
it worked great