Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Do local scripts work in surface guis?

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)

2 answers

✓ Accepted answer

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.

2 comments

0

Thank you :)

0

No problem.

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".

This discussion is preserved as it was. New answers, comments, and votes are closed.