#Hotbar Buttons
1 messages · Page 1 of 1 (latest)
local function onButtonClick()
print("Button clicked!")
end
button.MouseButton1Click:Connect(onButtonClick)```
Code inside the LocalScript
Your text button is your script.Parent
Your waiting for child in your Textbutton for a Textbutton
so im not dumb im stupid?
Try remove it down to just script.parent and add a task.wait(2) for now above it
If that works bravo
wait so where should i put the loca lscript
Startercharacterscripts
kk
local function onButtonClick()
print("Button clicked!")
end
button.MouseButton1Click:Connect(onButtonClick)```
@mild pulsar
Now run it, check for errors in the output
If that fails add a print(button) after the button variable assignment
Also put the task wait before, you want to make sure it loads in before you try reference it
local function onButtonClick()
print("Button clicked!")
end
button.MouseButton1Click:Connect(onButtonClick)```
Yes
Gng you sure this is where your script is?
This isn't a different script
I ain't seeing a Sydney sweeney
😭
Oh I think it's getting replicated to your character during runtime
Alright scrap that
Reference the button from workspace
You got a million things to go through sadly
Game.workspace etc
kill me
Yes it's alot of referencing lol but it should auto highlight
should i like search smth up?
in the workspasce
You need to reference from
game.Workspace
All the way down to your button
Oh wait I'm dumb not workspace
Startergui
i was like, workspace?!?
😭
dude had me rethinking life
** You are now Level 6! **
You could always put the local script in the button
Then do script.parent
Save yourself some time
Just remember where your script is
Or name it so you can search it later
as in this?
local function onButtonClick()
print("Button clicked!")
end
button.MouseButton1Click:Connect(onButtonClick)```
into that button?
Yep the button should be put into playergui in runtime and your localscript in it
So it should be able to reference it like that
okay
So should I have that same code in both the text button, and under startercharacterscripts?
I was wrong about startercharacter you don't need a script in there for this
Only in the button
local button = script.Parent
print(button.Name,"this")
local function onButtonClick()
print("Button clicked!")
end
button.MouseButton1Click:Connect(onButtonClick)```
Do that
Should print TextButton this
@mild pulsar it printed it
should it work now?
It should have you clicked the button
If it's not working 3 possible issues
- it's not in startergui
- it's not a local script
- another script is interfering
It is a localscript
yerp
ill do that now
still doesnt work
Then I have no idea either I'm forgetting something or one of your scripts is getting in the way
should i run it in studio n see
Probably using waitforchild In something that doesnt exist but idk
Have you not run it in studio and clicked the button?
no i tried it in game 😭
it works in studio
js tried it
still none of those hotbar buttons work in game
The only possible thought is it's not in startergui
If it is then Im not sure, I've made a couple games and I haven't had this issue
I actually have a last idea
alr
while not script.Parent do
task.wait()
end
local parent = script.Parent
Add that so we wait for the button gui
so where should i put it
the same localscript we have the other one in
?
No
Remove parent = script.Parent
Then your good
And you can remove the task.wait
the one with the (2)?
task.wait()
end
local
task.wait(2)
local button = script.Parent
print(button.Name,"this")
local function onButtonClick()
print("Button clicked!")
end
button.MouseButton1Click:Connect(onButtonClick)```
Yes
kk
while not script.Parent do
task.wait()
end
local button = script.Parent
print(button.Name,"this")
local function onButtonClick()
print("Button clicked!")
end
button.MouseButton1Click:Connect(onButtonClick)```
yeah this gotta be like unfixable
Let's hope pyro got you
yeah
Not really startergui is replicated to each client during run time
So in theory you should be able to reference the button with script.Parent so idk what the issue us
oh, do u have any friends that might know?
Not at 4am I don't lol
oh its 4am for u dang
alr ima head to bed tho its 11 for me
thanks for your help
@worthy pendant ^
ill look through it then
kk
can you send a screenshot of the console in game after the button press?
yeah lemme do it rq
** You are now Level 7! **
wait in studio or the actual game
actual game
kk
but it still didnt work
then where are the button clicked prints coming from
yeah, thats the script working no?
yeah but like the button wont actually work
the only thing this script does is print
is there a different script you're talking about
no
then yeah, the button isnt doing anything else because its not scripted to do anything else
all it does is print the name of the button and print everytime its clicked, which is what its doing
so waht script should i use
script it so that it has the functionality you want from it, what is it supposed to do?
It supposed to open a menu that has all the cases you can open on it
then reference the menu in your script, and when the button is pressed make it visible. We cant really write scripts for you here but try it yourself and come back when you are stuck
ill try this
script.Parent.Parent.Parent.Cases.Visible = true
end)```
@worthy pendant this doesn't work
i also tried
script.Parent.Parent.Parent.Visible=true
end)
@summer sage are you referencing the right thing, and add a print statement inside the activated function to make sure the button itself is still working
I believe i am ?
print("cases opened!")
script.Parent.Parent.Parent.Visible=true
end)```
send screen shot of the explorer with the script and the cases frame
(HotBarLocalScript)
is the script
the cases is only the parent of the button, so you only need
script.Parent.Parent.Visible = true
alr ill try it and lyk
still doesnt work
what does cases normally look like?
do the same thing you did here, but change the print statement to
print(script.Parent.Parent.Name, script.Parent.Parent.Visble)
and tell me what happens
and
put it after you change the visibility
its rly there to make sure the name is right, the visibility print is kinda redundant
script.Parent.Parent.Parent.Visible=true
print(script.Parent.Parent.Name, script.Parent.Parent.Visble)
end)```
this?
oh
script.Parent.Activated:Connect(function()
script.Parent.Parent.Visible=true
print(script.Parent.Parent.Name, script.Parent.Parent.Visble)
end)
alr
this thing feels unfixable
guess we'll see rn
we just doing some debugging right there, there is almost always a way to do smth
yeah still doesnt work
what is it printing
yeah i see
on the print
smallest errors ever 🤣
also you dont need to keep testing in game, you can stay on studio for now
oh okay
these errors should also be popping up there
so the cases is visible somewhere, but just not on screen for some reason
i suppose
is the cases frame always in the same spot, meaning you arent moving it at all?
Is the Active property of cases enabled?
or is there anything else messing with it, like at all?
so what are you doing to cases to make it invisible at the start of the game
no clue
cause it works in studio
studio can do some weird things with what ui is visible and isnt
all the buttons to the left and right of the middle X dont work in game but all work in studio
all of those buttons are scripted?
so like, there is no script, anywhere for those buttons, but when you press them, they open the correct ui, and it works as intended
yep
all those guis
"custom'" "game select"
etc
all work
with no script
bro has ghosts in his studio
😭
do you have any ui plugins or anything
i can hop on screenshare if u want rq
ye sure
general 2 or dms