#SurfaceGUI Button Problem

1 messages · Page 1 of 1 (latest)

rough slate
#

I'm trying to make it print "Hello World" when the user presses a text button inside of a surface gui but nothing prints...

dense field
#

Script?

rough slate
#
local button = script.Parent

button.MouseButton1Click:Connect(function()
    print("Hello World")
end)
#

very simple.

#

idk the issue

#

script.parent being the button

dense field
#

Activated is a better practice than mousebutton1click

rough slate
#

local button = script.Parent

button.Activated:Connect(function()
print("Hello World")
end)

#

nothing prints when i click it

#

its legit just meant to print "Hello world" when i press the buy button.

hard thorn
#

ur using a local right

dense field
#

oh

void magnetBOT
#

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

dense field
#

...

rough slate
dense field
#

dude you cant use local scripts in workspace

rough slate
#

how am i meant to make it work then

#

i jst want it to print hello world when they click it

dense field
#

use it in starterplayer or starter character scripts

hard thorn
#

ye

#

starterplayer

dense field
#

yea

rough slate
#

so i just change local button = script.Parent to the path to it?

dense field
#

yea

hard thorn
#

yes

rough slate
#

alr

#

big path

#

whats the best way to define that path

dense field
#

manualy 😭

rough slate
#

legit workspace.Map.Area1________

dense field
#

yea

rough slate
#

alr

dense field
#

you can only use local scripts inside starterplayer, startergui and starterpack

rough slate
#

12:03:46.823 MainBoard is not a valid member of Model "Workspace.Map.Area1.StarterArea.UpgradeBoards.MainBoards.Important.Upgrades" - Client - LocalScript:1

#
local button = workspace.Map.Area1.StarterArea.UpgradeBoards.MainBoards.Important.Upgrades.MainBoard.Upgrades.Main.CurrencyIncrease.Buy

button.Activated:Connect(function()
    print("Hello World")
end)
#

its the part tho

#

im confuzzled

dense field
#

its because the map might have not loaded in yet

#

you gotta use wait for child

rough slate
#

ok

dense field
#

on server scripts everything is there

rough slate
#

omg it works

#

❤️

#

ily broooo

void magnetBOT
#

studio** You are now Level 1! **studio

dense field
#

but for client everything is loading

#

np :D

rough slate
#

is there like a feedback place

#

to leave u feedback

dense field
#

nope