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

4 comments
But localscripts don't work in workspace?
If you parent the local script to the button, and the button is in StarterGui, then the local script will run
You can have the local script anywhere it will run really (StarterPlayerScripts for example). You just need to get a reference to the button from the script, and having the script parented to the button makes that easier
It's SURFACE GUI not playergui