#Hotbar Buttons

1 messages · Page 1 of 1 (latest)

summer sage
#

My hotbar buttons are only working in studio testing, and not in the actual game published.

#

local function onButtonClick()
    print("Button clicked!")

end

button.MouseButton1Click:Connect(onButtonClick)```
#

Code inside the LocalScript

mild pulsar
#

Your text button is your script.Parent

#

Your waiting for child in your Textbutton for a Textbutton

summer sage
mild pulsar
#

Try remove it down to just script.parent and add a task.wait(2) for now above it

#

If that works bravo

summer sage
mild pulsar
#

Startercharacterscripts

summer sage
#

local function onButtonClick()
    print("Button clicked!")

end

button.MouseButton1Click:Connect(onButtonClick)```
#

@mild pulsar

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

summer sage
mild pulsar
#

Yes

summer sage
mild pulsar
#

Interesting model name

#

Errors and good

#

So button is referencing to a model rn

mild pulsar
# summer sage

Gng you sure this is where your script is?
This isn't a different script

#

I ain't seeing a Sydney sweeney

summer sage
summer sage
mild pulsar
#

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

summer sage
#

kill me

mild pulsar
#

Yes it's alot of referencing lol but it should auto highlight

summer sage
#

in the workspasce

mild pulsar
#

You need to reference from

game.Workspace

All the way down to your button

#

Oh wait I'm dumb not workspace

#

Startergui

summer sage
#

😭

#

dude had me rethinking life

upbeat cliffBOT
#

studio** You are now Level 6! **studio

mild pulsar
#

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

summer sage
#

local function onButtonClick()
    print("Button clicked!")

end

button.MouseButton1Click:Connect(onButtonClick)```
#

into that button?

mild pulsar
#

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

summer sage
mild pulsar
#

I was wrong about startercharacter you don't need a script in there for this

#

Only in the button

summer sage
#

oh

#

oky

mild pulsar
#
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

summer sage
#

@mild pulsar it printed it

#

should it work now?

mild pulsar
#

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

summer sage
#

letsj s make sure

#

like that?

mild pulsar
#

You have so many frames

#

I cant tell where eit actually is

summer sage
mild pulsar
#

Buts it's a localscript

#

Have you tried the button?

summer sage
#

ill do that now

summer sage
mild pulsar
#

Then I have no idea either I'm forgetting something or one of your scripts is getting in the way

summer sage
mild pulsar
#

Probably using waitforchild In something that doesnt exist but idk

#

Have you not run it in studio and clicked the button?

summer sage
#

it works in studio

#

js tried it

#

still none of those hotbar buttons work in game

mild pulsar
#

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

summer sage
mild pulsar
#

Almost there

#

Just a bit further up

summer sage
mild pulsar
#

I actually have a last idea

summer sage
#

alr

mild pulsar
#

while not script.Parent do
task.wait()
end
local parent = script.Parent

#

Add that so we wait for the button gui

summer sage
#

the same localscript we have the other one in

#

?

mild pulsar
#

Yes

#

At the top

summer sage
#

kk

mild pulsar
#

No

#

Remove parent = script.Parent

#

Then your good

#

And you can remove the task.wait

summer sage
#
    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)```
mild pulsar
#

Yes

summer sage
#

kk

mild pulsar
#
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)```
summer sage
#

alr ill try it

#

works in studio

#

still doesnt work in game

summer sage
mild pulsar
#

Let's hope pyro got you

summer sage
summer sage
#

so theres nothing wrong over ehre

mild pulsar
#

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

summer sage
mild pulsar
#

Not at 4am I don't lol

summer sage
#

alr ima head to bed tho its 11 for me

#

thanks for your help

summer sage
#

@worthy pendant ^

worthy pendant
#

ill look through it then

summer sage
worthy pendant
# summer sage kk

can you send a screenshot of the console in game after the button press?

upbeat cliffBOT
#

studio** You are now Level 7! **studio

summer sage
worthy pendant
#

actual game

summer sage
worthy pendant
summer sage
worthy pendant
#

yeah, thats the script working no?

summer sage
#

yeah but like the button wont actually work

worthy pendant
#

the only thing this script does is print

#

is there a different script you're talking about

worthy pendant
#

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

worthy pendant
#

script it so that it has the functionality you want from it, what is it supposed to do?

summer sage
worthy pendant
#

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

summer sage
#
    script.Parent.Parent.Parent.Cases.Visible = true
end)```
summer sage
#

i also tried

#
    script.Parent.Parent.Parent.Visible=true
end)
worthy pendant
#

@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

summer sage
#
    print("cases opened!")
    script.Parent.Parent.Parent.Visible=true
end)```
worthy pendant
#

send screen shot of the explorer with the script and the cases frame

summer sage
#

(HotBarLocalScript)

#

is the script

worthy pendant
#

the cases is only the parent of the button, so you only need

script.Parent.Parent.Visible = true
worthy pendant
#

what does cases normally look like?

worthy pendant
#

and

#

put it after you change the visibility

#

its rly there to make sure the name is right, the visibility print is kinda redundant

summer sage
#

this?

worthy pendant
#

yes

#

wait no

summer sage
#

oh

worthy pendant
#

remove the extra parent in line 2

#

then yes

summer sage
#

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

worthy pendant
#

we just doing some debugging right there, there is almost always a way to do smth

summer sage
#

yeah still doesnt work

worthy pendant
#

what is it printing

summer sage
worthy pendant
#

visible is mispelled

#

you are missing in "I" between s and b

summer sage
#

yeah i see

summer sage
#

smallest errors ever 🤣

worthy pendant
#

also you dont need to keep testing in game, you can stay on studio for now

worthy pendant
#

these errors should also be popping up there

summer sage
#

well it printed

worthy pendant
#

so the cases is visible somewhere, but just not on screen for some reason

worthy pendant
#

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?

summer sage
#

its sure active

worthy pendant
#

so what are you doing to cases to make it invisible at the start of the game

summer sage
#

cause it works in studio

worthy pendant
#

studio can do some weird things with what ui is visible and isnt

summer sage
#

all the buttons to the left and right of the middle X dont work in game but all work in studio

worthy pendant
#

all of those buttons are scripted?

summer sage
#

so no idea whats happening

worthy pendant
#

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

summer sage
#

all those guis

#

"custom'" "game select"

#

etc

#

all work

#

with no script

worthy pendant
#

bro has ghosts in his studio

summer sage
worthy pendant
#

do you have any ui plugins or anything

summer sage
#

i can hop on screenshare if u want rq

worthy pendant
#

ye sure

summer sage
#

which

worthy pendant
#

general 2 or dms