I am trying to make a surface gui button that opens up a screen gui, but when I insert a local script into the button in the surface gui, nothing happens. I tried to print hello world and nothing happened. Nothing printed, no errors, nothing, but when I move it into starterplayerscripts everything works just fine. Do local scripts work in surface gui or am I just doing something wrong? Heres the local script:
local button = script.Parent local internet = game.StarterGui.Screen.Internet local InternetSender = game.ReplicatedStorage.RemoteFunctions.Screen:FindFirstChild("InternetOn") local function onInternetSender(player) print(player) InternetSender:FireClient(player) end button.MouseButton1Click:Connect(onInternetSender)
You have to insert a SurfaceGui
into StarterGui and set the Adornee property to the part that the text is supposed to appear on. Then insert a TextButton
into the SurfaceGui and put the script you used inside the TextButton. Also, I know this isn't related to the question, but you used :FireClient()
inside a LocalScript, which would error since it's only accessible to ServerScripts.
It should, Many games have that for menu screens and stuff that is localside. Make sure you don't do a me and make a textlabel for your "textbutton".