So I have a surface gui where you talk to a person (server script!) it does work in studio, but it doesn't detect a click when in a real server, buttons can change text though and subtitles work fine, here is the part that doesn't work (there are multiple of that (almost) same code, I DON'T GET ANY ERRORS!
button1.MouseButton1Click:connect(function(plr) if clicked == 0 then clicked = 1 AnswerTime = false StoryPlay = 1 end end)
the script is too long to copy so I'll set the variables and some other stuff here
local button1 = workspace.StoryLine.Conversation.ButtonsLeft.SurfaceGui.ButtonTop local button2 = workspace.StoryLine.Conversation.ButtonsLeft.SurfaceGui.ButtonDown local button3 = workspace.StoryLine.Conversation.ButtonsRight.SurfaceGui.ButtonTop local button4 = workspace.StoryLine.Conversation.ButtonsRight.SurfaceGui.ButtonDown local subtitles = workspace.StoryLine.Conversation.Subtitles.SurfaceGui.Subtitles IntroEnded = false StoryPlay = 0 clicked = 0 AnswerTime = false minDelay = 0.1 buttonDelay = 0.5 textDelay = 2 button1.Text = "" button2.Text = "" button3.Text = "" button4.Text = "" --subtitles.Text = "Good morning, U.G.S here!" subtitles.Text = "" wait(1) subtitles.Text = "G" wait(minDelay) subtitles.Text = "Go" wait(minDelay) subtitles.Text = "Goo" wait(minDelay) subtitles.Text = "Good" wait(minDelay) subtitles.Text = "Good m" wait(minDelay) subtitles.Text = "Good mo" wait(minDelay) subtitles.Text = "Good mor" wait(minDelay) subtitles.Text = "Good morn" wait(minDelay) subtitles.Text = "Good morni" wait(minDelay) subtitles.Text = "Good mornin" wait(minDelay) subtitles.Text = "Good morning" wait(minDelay) subtitles.Text = "Good morning," wait(minDelay) subtitles.Text = "Good morning, " wait(minDelay) subtitles.Text = "Good morning, U" wait(minDelay) subtitles.Text = "Good morning, U." wait(minDelay) subtitles.Text = "Good morning, U.G" wait(minDelay) subtitles.Text = "Good morning, U.G." wait(minDelay) subtitles.Text = "Good morning, U.G.S" wait(minDelay) subtitles.Text = "Good morning, U.G.S " wait(minDelay) subtitles.Text = "Good morning, U.G.S h" wait(minDelay) subtitles.Text = "Good morning, U.G.S he" wait(minDelay) subtitles.Text = "Good morning, U.G.S her" wait(minDelay) subtitles.Text = "Good morning, U.G.S here" wait(minDelay) subtitles.Text = "Good morning, U.G.S here!" wait(buttonDelay) button1.Text = "Who are you guys?" wait(buttonDelay) button2.Text = "Hello!" wait(buttonDelay) button3.Text = "Go on!" wait(buttonDelay) button4.Text = "I'm not interested :/" wait(buttonDelay) AnswerTime = true IntroEnded = true repeat wait(minDelay) button1.MouseButton1Click:connect(function(plr) if clicked == 0 then clicked = 1 AnswerTime = false StoryPlay = 1 end end) button2.MouseButton1Click:connect(function(plr) if clicked == 0 then clicked = 1 StoryPlay = 2 end end) button3.MouseButton1Click:connect(function(plr) if clicked == 0 then clicked = 1 AnswerTime = false StoryPlay = 3 end end) button4.MouseButton1Click:connect(function(plr) if clicked == 0 then clicked = 1 AnswerTime = false StoryPlay = 4 end end) until AnswerTime == false
GuiButton.MouseButton1Click will only fire in local scripts. You will need to use a remote event if you want to interact with the server on button click.
Put the surfaceGui inside of the Client's PlayerGui (or startergui, if you want to) And set it's Adornee property to the part you want it on. Then you can use Localscripts from the client to interact with it.