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:
local RS = game:GetService("ReplicatedStorage") local AnnounceEvent = RS:WaitForChild("AnnounceEvent") AnnounceEvent.OnServerEvent:Connect(function(player) AnnounceEvent:FireClient() end)
LOCALSCRIPT:
local player = game:GetService("Players").LocalPlayer local PlayerName = player.DisplayName local RS = game:GetService("ReplicatedStorage") local AnnounceEvent = RS:WaitForChild("AnnounceEvent") local text = player.PlayerGui.Announce.TextLabel local text2 = player.PlayerGui.Roll.TextLabel local button = player.PlayerGui.Roll.TextButton local value = player.PlayerGui.Roll.Value button.MouseButton1Click:Connect(function() text.Text = PlayerName..' has rolled '..text2.Text AnnounceEvent:FireServer(text.Text) 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:
script.Parent.MouseButton1Click:Connect(function() script.Parent.Text = --your text here 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:
local RS = game:GetService("ReplicatedStorage") local AnnounceEvent = RS:WaitForChild("AnnounceEvent") AnnounceEvent.OnServerEvent:Connect(function(player) AnnounceEvent:FireAllClients() 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.