#problems with scripting

1 messages · Page 1 of 1 (latest)

tiny path
#

ive been scripting for a few days now this is a little out of what i can but im trying
i want to make the Pop up screenGui disable when clicking on On/off Button

gentle trench
tiny path
#

Close is not a valid member of ImageLabel "Players.Jamal73938.PlayerGui.Settings.Frame .ImageLabel"
Close is not a valid member of ImageLabel "Players.Jamal73938.PlayerGui.Settings.Frame .ImageLabel"

#

it says it cant find the Pop up and the OffButton

gentle trench
#

Additionally I would be careful with your naming, you have two objects in the explorer called "Pop up", which can cause a lot of unintented problems

#

but that might not be related to your problem let me see

tiny path
gentle trench
#

is this the right error message? Looks like its coming from a different script

tiny path
#

wait lemme see

gentle trench
#

if you click on the error in the console it should take you to the script its coming from

tiny path
#

it only says this when i remove the script
Close is not a valid member of ImageLabel "Players.Jamal73938.PlayerGui.Settings.Frame .ImageLabel"

#

ow yeah i know its just a script but its not rlly a problem hold on

#

it makes the setting tab come up ur right thats not the problem but

#

i want to make a setting to turn off pop ups

#

it does say it cant find the Pop up and the OffButton

gentle trench
#

Then it could be the name, I would recommend finding a different name for one of the duplicate "Pop up" screen guis you have in your game, it could be that the script is using the one that you arent expecting

tiny path
#

alright ill change it

gentle trench
#

then update the reference in the script if needed

tiny path
#

its now called Pp up

#

changed it in the script ill tryµ

gentle trench
#

Thats an interesting name but we will worry about it in a sec lol

tiny path
#

alr its not working 😦

#

dangit

gentle trench
#

any errors?

#

wait you named them both pp up

#

they need to have different names

#

are you trying to disable them both or just one?

#

because there is a different way to do so

tiny path
#

both

#

im trying to disable everything with the name Pp up when clicking on OnButton

gentle trench
#

Try putting each pop up gui in a folder instead

#

then we can loop through that folder and disable each gui inside

#

I can teach how if needed

tiny path
#

Infinite yield possible on 'Players.Jamal73938.PlayerGui:WaitForChild("Pop up")'

tiny path
gentle trench
#

yeah you will have to chnage every reference related to your pop ups to account for the folder

#

but name the folder something like "Pop ups", the name of the guis doesnt matter anymore they can be the same

tiny path
#

good?

gentle trench
#

yes

#

then you disable them, you will make a variable that will hold a table (list) of every object in that folder, ex:

-- remove the space on your popups folder
local popUps = playerGui.PopUps:GetChildren()
#

then you can loop through each object in this folder and disable them individually

for _, popUp in pairs(popUps) do
  popUp.Enabled = false
end
tiny path
#

ill try but im not that good at scripting im trying to learn it tho i know what a function is

#

ill try to loop it

gentle trench
#

You mean the GetChildren() function?

#

i can explain

tiny path
#

alrr

ionic badgerBOT
#

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

gentle trench
#

The getChildren function looks at an object in the exploerer and puts every child inside of it into a table. for example, lets say I have a screenGui with 4 frames inside of it, name frame1, frame2, ... etc.
When I use :GetChildren() on the screen gui, it will return this
{frame1, frame2, frame3, frame4} and save it as a variable

tiny path
#

okay okay i think i get it

gentle trench
#

then the loop will loop through each item in the list one by one, and will set the popUp variable we made to each item in the list, so when we disable the guis for example, we are going through each gui one by one in the table we made, and running code on it

tiny path
#

oooohh aight aight

#

ty bro

gentle trench
#

np, see if you can do it yourself

#

ping me if needed

tiny path
#

alr

gentle trench
#

im trying to get better teaching stuff like this

tiny path
#

ur good lemme say that

#

@gentle trench do i put it like this?

#

is this good?

gentle trench
#

if thats not what you want then i would just move the settings screen gui outside of it

tiny path
#

oh yeah it disables

#

omg the script works

gentle trench
#

woah was not expecting that, sick

tiny path
#

but yea like u sayed the settings go away to ill try to fix

#

and it only goes away after like 1à sec not if i click on the button :('

#

almost

#

fixed the cooldown

gentle trench
#

so is it working or is there something else that needs working on?

tiny path
#

i only want it to go away when i click on the On/off Button

#

i can put a cooldown for when putting it off but i cant get it like to click and then it disables

gentle trench
#

then move the script we made inside of an event that only fires when the on/off button activates

tiny path
#

whats an event? where do i put it?

#

sorry if im dumb

gentle trench
#

an event is like your .MouseButton1Click you had on your button before

tiny path
#

oh yeaahh

gentle trench
#

.Activated basically does the same thing but is more universal, invludes mobile device taps and im pretty sure xbox inputs aswell

#

but im not sure

tiny path
#

alr alr thats good

gentle trench
#

so you will do

on/offButton.Activated:Connect(function()
  local popUps = playerGui.popUps:GetChildren()
  for _, popUp in pairs(popUps) do
    popUp.Enabled = false
  end
end
#

you will have to change each undefined variable you what you have in your game

#

but thats an example code of what im getting at

tiny path
#

lemme show u what i came up with that was sadly not working

gentle trench
#

k

tiny path
#

i added this
if screenGui and offButton and onButton then

offButton.MouseButton1Click:Connect(function()
    screenGui.Enabled = false  
end)


onButton.MouseButton1Click:Connect(function()
    screenGui.Enabled = true  
end)
gentle trench
tiny path
#

THE CLICK

#

caps

#

mb

#

it just doesnt do it

gentle trench
#

lol, put a print statement under each event and see what happens when you try to click the button

#

oh wait

ionic badgerBOT
#

studio** You are now Level 10! **studio

tiny path
#

Infinite yield possible on 'Players.Jamal73938.PlayerGui:WaitForChild("Pop up")
it says this

gentle trench
#

hold up i know why

gentle trench
tiny path
#

okay

gentle trench
#

does "Pop up" exist?

#

its looking directly in the player gui for something with that name, if it doesnt exist then that that warning will occur

tiny path
#

fuck i changed it

#

i forgot

#

huh

#

it still says the same

tiny path
#

yea

#

and i put an

#

else
print("blabla

gentle trench
#

let me see your explorer

tiny path
#

THIS IS THE SCRIPT

#

caps

#

again

gentle trench
#

Change "Pop up" to "PopUps", the name is still different

#

oh wait

#

can you copy and paste the exact warning again?

tiny path
#

Infinite yield possible on 'Players.Jamal73938.PlayerGui:WaitForChild("Pop up")'
its just this

ionic badgerBOT
#

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

gentle trench
tiny path
#

it could be but i cant seem to find it then

gentle trench
#

click on the warning and it will send you there

tiny path
#

its an orange one

#

i cant

#

also the print is showing

#

the else print

gentle trench
#

the "not working" one?

tiny path
#

yea

gentle trench
#

I would recommend getting rid of that if and else statement, and move your events outside of it, to see what exactly isnt being defined there

tiny path
#

wait yo

#

found the pop up thing

gentle trench
#

nice

tiny path
#

everything still works wheni remove the script so yeah

#

now when i click it there is no issues but its not working tho

gentle trench
tiny path
#

the one i deleted

#

the picture one is in the folder

#

and it works but just not with the button

gentle trench
#

send new screenshot

tiny path
#

could be handy

gentle trench
#

Ok so let me inplement the code a little better, because we dont need the screenGui.Enabled = false line 16 anymore. So move lines 8-11 inside that event in replacement of it.

#

Additionally its a interesting thing you learned but I would get rid of your line 13 if statement, it is redundant as it is checking if anything is undefined, but that will be automatically handled from us attempting to define it

tiny path
#

like this?

#

also the errors is nothing crucial

gentle trench
#

bring back your off button event

offButton.MouseButton1Click:Connect(function()
  -- lines 8-11 here
end
#

and remove the end on line 18 and move the lines 14-17 on indentation back

tiny path
#

like this right?

gentle trench
tiny path
#

now i have this

gentle trench
tiny path
#

like this

#

right?

gentle trench
#

yes, now just move lines 10-13 and 17-18 back one space

#

has no effect on the code but it helps readability

tiny path
gentle trench
#

no like, un-tab it back towards the left

tiny path
#

this then

gentle trench
#

yes do that for 11-14 aswell

tiny path
gentle trench
#

wait no tab it forwards 1

tiny path
#

like thius

tiny path
#

soirryy

gentle trench
#

tab 12 once, and 13 twice

#

this should be it

tiny path
#

bam

#

thats it right?

gentle trench
#

yes

#

noice

#

that should be the off button, we will make the on button when we are sure it works

#

try it

tiny path
#

no man 😦

#

fuckkkkkkkkkkkkkkkkkkkkkkkkk

#

Infinite yield possible on 'Players.Jamal73938.PlayerGui.PopUps.Pp up:WaitForChild("OffButton")'

#

honestly if u want to we could do this another time its getting late for prob both of us

gentle trench
#

if you want, you can dm me when you are back, cause its only 6 pm for me

tiny path
#

alr its 00:30 here

gentle trench
#

oof

tiny path
#

but i cant sleep with a loss yk

gentle trench
#

lol coding will have you at a loss for a couple of days, you'll be fine

tiny path
#

whah

#

alr alr

#

i think the problem is here thoi

#

with the buttons and sh

#

im 90% sure

gentle trench
#

probably

tiny path
#

this is the whole thing

#

so w8

#

lemme try

#

nope

gentle trench
#

i think you are looking for the buttons i the wrong spot

#

it looks like the game needs way more steps to get to the on and off buttons than you have in your script

tiny path
#

yeah i thought that to

#

i wasnt sure tho

gentle trench
#

you should be able to do that then, just update the script to get to the button with the proper steps

tiny path
#

alr

#

i tried fixing it didnt work im sleepy ima head off ill dm u if needed k?