Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Do local scripts work in surface guis?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

0
Thank you :) xualex10 3 — 4y
0
No problem. youtubemasterWOW 2741 — 4y
Ad
Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
4 years ago

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

Answer this question