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

Surface gui buttons don't work in real servers?

Asked by 6 years ago

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

2 answers

Log in to vote
0
Answered by 6 years ago

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.

0
But localscripts don't work in workspace? User#20388 0 — 6y
0
If you parent the local script to the button, and the button is in StarterGui, then the local script will run vector3_zero 1056 — 6y
0
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 vector3_zero 1056 — 6y
0
It's SURFACE GUI not playergui Shadowman670 -4 — 6y
Ad
Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
6 years ago

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.

Answer this question