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

How do I change a SurfaceGui for everyone in an FE server?

Asked by 6 years ago

I'm just really struggling with something right now

Basically, when a player in an FE game clicks a button on a ScreenGui, I need a SurfaceGui in Workspace to update its TextLabel.Text I don't know how to do this and its really fraustrating!! I've been trying to use RemoteEvents, but how do I make the change on the SurfaceGui replicate to everyone in the server?

Any help would be appriciated, thanks in advance.

1 answer

Log in to vote
0
Answered by 6 years ago

Okay, so you need to put a LocalScript in StarterGui and a Script in ServerScriptStorage. You will also need to put the ScreenGui in StarterGui.

Yes, you will need RemoteEvents, so put one in ReplicatedStorage and name it what you want.

Now, in the LocalScript you will need it to fire the RemoteEvent when the player clicks on the ScreenGui element. It should look like this:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage.RemoteEvent
local TextButton = script.Parent.ScreenGui.TextButton

TextButton.MouseButton1Down:connect(function()
    RemoteEvent:FireServer("VIP") -- The text you want to appear in the TextLabel
end

Now in the Script you will need to define what happens when the button is pressed.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage.RemoteEvent
local TextLabel = game.Workspace.SurfaceGui.TextLabel

RemoteEvent.OnServerEvent:connect(function(plr, text)
    TextLabel.Text = text
end

That answer took me long to make so I'd appreciate if you marked this as the answer and gave it an upvote. Hope I helped you!

0
Great example, I haven't had the chance to try it yet to see if it works, but I think I tried something similar earlier and it only changed the SurfaceGui TextLabel for the client who clicked the ScreenGui button. Will this change the SurfaceGui for everyone? TimothyE33 4 — 6y
0
Well, it should because it's the server that changes the text. The client only sends a message through a RemoteEvent so the server changes the text. Tymberlejk 143 — 6y
Ad

Answer this question