Hello there, I made a LocalScript, a script and a RemoteEvent for my current situation that I have which is that a TextLabel changes it's text for all players to see when a player presses a button, but it does not seem to work, How do I fix this?
SERVERSCRIPT:
1 | local RS = game:GetService( "ReplicatedStorage" ) |
2 | local AnnounceEvent = RS:WaitForChild( "AnnounceEvent" ) |
3 |
4 | AnnounceEvent.OnServerEvent:Connect( function (player) |
5 | AnnounceEvent:FireClient() |
6 | end ) |
LOCALSCRIPT:
01 | local player = game:GetService( "Players" ).LocalPlayer |
02 |
03 | local PlayerName = player.DisplayName |
04 | local RS = game:GetService( "ReplicatedStorage" ) |
05 | local AnnounceEvent = RS:WaitForChild( "AnnounceEvent" ) |
06 | local text = player.PlayerGui.Announce.TextLabel |
07 | local text 2 = player.PlayerGui.Roll.TextLabel |
08 | local button = player.PlayerGui.Roll.TextButton |
09 | local value = player.PlayerGui.Roll.Value |
10 |
11 | button.MouseButton 1 Click:Connect( function () |
12 | text.Text = PlayerName.. ' has rolled ' ..text 2. Text |
13 | AnnounceEvent:FireServer(text.Text) |
14 | end ) |
Hi there!
There is actually a very simple one.
So you can remove the Script in ServerScriptService or where you have it and the RemoteEvent.
Add a Script to the button and place this in it:
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | script.Parent.Text = --your text here |
3 | end ) |
A LocalScript is for the player that is seeing it so not the entire server, a Script is for the entire server.
Simply, you should use remote:FireAllClients() instead of FireClient. So you should put that in your server script:
1 | local RS = game:GetService( "ReplicatedStorage" ) |
2 | local AnnounceEvent = RS:WaitForChild( "AnnounceEvent" ) |
3 |
4 | AnnounceEvent.OnServerEvent:Connect( function (player) |
5 | AnnounceEvent:FireAllClients() |
6 | end ) |
And now you need an local script in gui that activates when announce event fires on client. If it wont work or there will be any error in output let me know.