✓ Accepted answer
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")
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!
2 comments
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?
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.